Unwanted Xano data over-write from weweb workflow

I have a Weweb workflow that updates a user’s profile information in Xano. I have a form that has half a dozen of the user fields on it. The WF is set to edit the Xano fields with the contents of each input field. When I run the WF, the input fields correctly overwrite the Xano data in those fields. BUT, there are other fields in that Xano table that had data in them to start with, but they are emptied when my workflow calls the edit API in Xano. How do I stop this from happening???

I’ve been there, Xano has a way of making sure that doesn’t happen and it should really be the first thing they tell you when you sign up lol.

Watch the video below and he will explain how to avoid this by setting up a filter called first_notempty

1 Like

thanks Mark

@fredo22 You have to be very careful with “first_notempty” filter. It considers the string '' empty, which is correct, but prevents your logic from clearing the field in the database. Additionally the string '0', which is clearly not empty will be cosidered as empty which is not true!.

The possible solution for this is to to make sure the input is nullable on the Xano side and that it is not set to a default value of a blank array. Then using “first_notnull” filter you will change only the fields values which are passed from WeWeb and empty string passed from WeWeb will erase the value in the databese field (as expected) and you will be able to use “0” as a value to insert into database.

Very good advice. This has been the trickiest part of getting Xano setup. I’ve found that in most situations, it’s easier to just bind the PUT input fields that are not being updated in a form to the original collection values. Easier when you don’t have a ton fields in the table.

Thanks @ericp I have approx 20 fields in that table. How exactly would I do this? “bind the PUT input fields that are not being updated in a form to the original collection values”

I wrote ‘PUT’, meant ‘POST’.

In the screenshot below, I’m updating an existing Xano record using a form. Using the ‘Location’ field as an example, it’s on the form and I’m updating the record with the form value (green ‘Location Answer - value’). If for some reason I didn’t want the user to have the ability to update this field, so I removed it from the form, I could still update the record using the existing value from the collection (blue ‘Location’) for that field. Effectively performs an update using the existing value.

This assumes that you have already fetched the existing record through a collection so the existing record values are available.

Question: how to get control of this when you do want empty the field in combination with either first_notempty and firstnot_null

For example

  • I want to have xano ignore the null/empty fields when these are not bound to the request in weweb upon request
  • on the other hand when I clear a field on an weweb form, I want that fieled to be cleared in Xano also?

@FHEXL First you have to edit your API input in XANO an set the parameter “NULLABLE” to YES.
Then follow the instructions from the video in @mark post but change filter name to “first_notnull”.
In such a case when the input does not receive any value i.e. it is not binded to anything in WeWeb it will be NULL instead of “”.

So when you pass empty string (or “0”) form WeWeb the data will be cleared in XANO and when you dont pass anything it will be NULLed and therefore not replaced in the datavase. This way and you do not have to think about it while connecting your data fileds in WeWeb.

@Dominic thanks. So I suppose that when I bind a weweb field value, and I empty the field on the form and submit it, Xano receives empty string “”.

@FHEXL exactly. And in if you are not using NULL you won’t be able to clear the data.

On the Xano Community I found this video with a nice workaround to create an actual PATCH Method.