How to change fields in an object with for each loop and conditional if?
Hi,
I want to loop through the fields in an object and set fields with a null value to contain the string "empty" instead. I'm trying to do it like this:
But when I hit the stop and debug, all the null fields in the object are still null.
What am I doing wrong here?
Thanks in advance.
Answers
-
Hi,
From what i can see when you used values filter on the object you pretty much turn in into list of values that no longer relates to that object so then when you are looping through every single one of the you are not updating a field in an object but a separate and completely new entity created by the filter.
-
Okay, makes sense. How would you do what I'm trying to do?
-
One way which is not very clean would be to use encode json filter then use replace filter to change null to empty and decode again. Remember to replace with empty as a string so "empty".
To propose something better let me see how the object looks like
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