Is there a way to create a condition to not create duplicate record and instead update the record? Let’s say we have a button trigger that creates a record; if I were to click it again, I want to update the record if the entry is already in the record.
A few ways to do this.
- You can check to see if a record exists with any ID:
- You can use the “Create or Load record” action that will automatically load a record if it exists, and create if if it doesnt.
Does one of these two do what you need?
So basically I created an ID with a randomstring(). With that being said, is there a way to check if the record has the same step name in the record and then therefore update the record with that specific step?
I got my app to create the record and update ONLY IF you are on the page. The moment you click out and click back, it creates a new ID and a new record instead of updating the record.
This makes it a little tricker, but not impossible. So the way I am going to do this is 2 fold:
- Filter my table to just the records with your matching station
- Get the count of records that match station name
- Get the ID of the records with a matching station name, if they exist.
Here is how I would do this in Tulip.
Add a query to your table, in this case I am filtering the department field, but you can filter on the station name
Create an aggregation that will calculate how many records match this criteria (if it is more than zero we want to load a record, not create one)
Create an aggregation that will return the record ids with a matching department
Now on the app side
Add your query to your table record
Add your two aggregations to that query
Now in your trigger we will check to see if the aggregation is more than 0 (if a record exists for this department, if it does we will pull the first item out of that list of ids, and load that record, if not we will create a new record.
Does this make some sense? There is working going on right now to make this process less painful.
Thank you so much for your input. I will try this out. If it doesn’t work, I’ll try my best to find another way around this soluton.
Thanks for your solution. I had another question though. If you go to the main menu in test mode, does it reset the table? Your method works if I go to previous steps and next steps, but as soon as I hit the main menu and go back to the steps, it creates new records.