NEW Conditional Set Filters
![Michael Udinski](https://us.v-cdn.net/6037124/user_avatars/1160710.jpg)
ADMIN
We added 4 new conditional set filters:
- first_notempty
- first_notnulll
- set_ifnotempty
- set_ifnotnull
These will come especially in handy if you are updating records or objects but you only wish to update a field if the input is not empty or not null. Check out the tutorial to see how you can use them.
Comments
-
Amazing ! can we add one more ? 😀 i suggested at request feature
-
- Do you have any suggestions on how to intentionally overwrite a value with a blank (essentially delete out the value) since clearing the input will not work now?
I am thinking we need the front end to pass a known delete value ([DELETE} or [NULL}, etc) but I was hoping, the bright minds over at Xano might have a cleaner way to handle this. -
- I just want to be sure that I'm following... you want to be able to not update something if the input is blank but also be able to clear it out at the same time with a blank value?
-
- We want to allow front end to pass only fields that have updates. Missing fields will keep current values. But how does the front end communicate when the user intends to clear the value from the field?
Existing values:
Name = Tim
Active = False
Message = This is a test
UPDATE:
Active = True
UPDATE:
Message = “”
Using SetIfEmpty so the second update works, the last update would not work. The previous value would set into the Message field. Any ideas on how to clear Message? -
Hi - definitely not the easiest on the eyes looking solution (esp if you have many fields) and certainly some nuance to think through in your front-end/UI but a solution is 100% possible, here's one way to think about:
https://www.loom.com/share/a78f25efab37499fbef6e443595d0335 -
- Thank you for making the video. We needed up with something similar but without the extra inputs and without tge front end having to add something for the user just the awareness of the empty field.
Here’s what we did:
If the field was not updated by the front end and so is missing then we use SetIfNotEmpty as stated before. However, if the front end passes a tag as the value on a field we catch that first and allow the value to be overwritten as empty in the EDIT.
By having the delete flag inside the value removes the need for extra inputs and UI controls. The front end just needs to apply the logic to add the when the user removes the value from the field.
I hope this helps others trying to build auto save forms on the front end as the user moves through each input value. -
Thanks for the video. first_notempty is working great for text and integer properties.
What conditional filter can I use for booleans? -
Is there a way to do this so that you do not even need to include the column in the JSON?
For instance
User_Table
• id
• name
• adress
I want to send the following JSON
{
id:3,
name: "Foo Bar"
}I want only name to be updated, and address to remain the same.
With first_ifNotNull, the above JSON clears the address field in the DB.
I cant use first_ifNotEmpty, because I want to be able to send {id: 1, address:""} and then set address to "". But, that then will not work with first_ifNotEmpty.
thank you for assistance. -
If anyone else is trying to use these on their authenticated user DB, note that you'll need to turn off "required" in the API input settings.
-
Would be nice to have real PUT/PATCH endpoints automatically generated. See the feature request #240
-
@gbdoin just FYI Xano still performs full object replacements regardless of the verb
-
@Michael Udinski yes indeed, the feature request mentions using the "first_not[…]" filters above on an "edit record" request for all input fields automatically.
This way, we could generate PATCH endpoints that actually patch the record without deleting the value if it is null (as an example for "first_notnull").
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback