what’s the current recommended approach to handle this kind of situation?
“update thing; if it doesn’t exist, create it”
currently I have two actions in my workflow for create/update with a condition, but if the id of the created/updated object is needed later on in the flow, I struggle to return one ID or the other conditionnally because the ‘format as text’ doesn’t return an object but text… and this kind of problem can easily scale up in the same flow…
Step 3
update thing B
parent_thingA = Search for thing A where unique Id = (step 1’s thing A is empty? if yes step 2 unique id, if no step 1 unique id) : first item
I wrote a mistake in my previous message which I just updated.
I need the search to conditionally apparent the thing B to either the existing thing A updated in step 1 or the newly created thing A created in step 2.
Why not just create a thing if the thing doesn’t exist (check this using a DB search) and make changes to the already existing thing (find it using a search) if result of step 1 is empty
yes that’s what I’m doing, I guess I was not clear in my answer?
I do create or update based on the record A existing or not, but then I need two actions to handle the option where the record already existed, and where it didn’t (or one action with my approach with the search).
though my original question was if there would be a better way to handle the “if it exists, update, if not create” but I guess not at the moment.
Hello Olivier ! Thanks a lot for sharing the experiment you did with us, I just read it.
Some feedback, I don’t think test one and two are completely equivalent because in scenario 1 you create a thing, in scenario 2 you create or update a thing, then update it again!
A fairer test in my opinion would be to also add the update (3rd step from scenario 2) to the scenario 1.
Moreover in a real use case the 3rd step wouldn’t be necessary, because we can already make the necessary changes in step 1 and 2.
In the case I was presenting earlier, the thing that needs updating in the last step of the flow is a child record “B” of thing “A” (whose reference we get from step 1 or 2).
Yes exactly, there are always more options to structuring something, this was just one example. I should have made that more clear in my LI post. Thanks for the feedback tho!