As everybody should do, I read this fundamental thread about Order of Operations in Workflows.
In his reply @aschofer among other interesting things says:
In a workflow with two actions, if Step 2 is using a condition based on a search depending on data manipulated in Step 1, then Step 1 should be implemented into a custom event to make sure it is finished before moving on to Step 2.
Well in my experience this, unfortunately, is not completely true. Let me explain.
Here’s the public app (I hope it works, first time I share an app)
CASE: in a WF I want to modify a field in the database and, as a result, set a value to a custom state.
SOLUTION 1, the WRONG one (it’s here for explanation sake)
I click the button that triggers the WF, but step 2 is (or better: could be) faster than step 1 and no value is assigned to the custom state.
SOLUTION 2. The one suggested by @aschofer
Also this solution unfortunately is not consistent, sometimes step 2 is executed before the completion of step 1.
SOLUTION 3. The only one giving consistent results.
As you can see I activate a “ping-pong” loop…
ending when it’s sure that the value in the Database has been updated.
SUMMING UP
I’m a little deceived by this behaviour and I think that an event like “wait until condition is met” should exist.
I think that solution 3 is, anyway, the best option if we want to be sure that there will be no surprises.
And in the end, coup de theatre!
To further complicate things if you play with the app you’ll notice that:
-
if you click trigger1 → reset → trigger1 ==> the 1st time everything looks fine but from the 2nd the CS is not updated (empty field).
-
Same behaviour for button trigger2
-
button trigger3 works all the time
-
BUT (and here I get mad) if you activate buttons trigger1 and/or trigger2 AFTER clicking trigger3 THEY ALWAYS WORK. (Bug? My mistake?)
(Refresh the page and you will see again the described behaviour).
If I did something wrong in this simple app please let me know, my mental sanity depends on this at the moment. Thank you.