Add or Edit Record by matching multiple fields
Options
Connor McCormick
Member ✭
I want to add or edit a record based on the data in multiple fields.
E.g. I want to edit a record if:
record.id == id AND record.date == date
But, if one of those doesn't match, I want to create a new row where
record.id = id, record.date = date, record.other_field = other_value
Is there a way to do this with the Add or Edit Record interface?
[image.png]
E.g. I want to edit a record if:
record.id == id AND record.date == date
But, if one of those doesn't match, I want to create a new row where
record.id = id, record.date = date, record.other_field = other_value
Is there a way to do this with the Add or Edit Record interface?
[image.png]
Comments
-
I don’t think you can use Add or Edit for this use case. You will probably need to use Query All and the use conditionals to edit if the query all returns a record or add a new record if it doesn’t. Not sure if others here have a better solution that can utilise Add or Edit
-
Hey, Connor. For this, I would use an if/then statement. This will check if record-id and record-date equal something, and if so, it will edit an existing record. If not, it will add a new record. Short and sweet.[image.png]
-
I ended up doing that, but there are some shortcomings:
1. If then statements take up a lot of space, are slower, and are harder to parse
2. I have to run a Query + an Edit/Add. If Add or Edit could match on multiple fields then I could do this whole thing in 1 line with 1 query instead of in 4 lines with 2 queries.
Maybe we can move this post over to feature requests? -
I'll definitely pass this along and see if I can bring some additional insight back for you. I do think that depending on how intense your logic is, and the volume of your requests, using an if/then for this is as efficient as it can be, especially considering that this is pretty much what would be happening behind the scenes regardless of if it was a conditional built into an Add/Edit function vs building the function stack manually.
-
+1 for this request.
It will definitely make the implementations cleaner and quicker.
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