So it was my understanding that workflows do not entirely follow the steps as we would expect. They execute in step order, but run in parallel, so they can finish in different times. So it’s possible that step 2 could run and complete before step 1 has a chance to complete, which could be problematic if step 2 needs step 1’s output.
From what I know, this can be avoided by either referencing the output of step 1 into step 2, so step 2 has to wait for step 1 to finish. Or, if you run a custom event in step 1, step 2 has to wait until the custom event in step 1 has finished.
However, neither of these has prevented a workflow I’m working on to somehow skip over and finish the the workflow.
So my case:
- I have a submit button that starts a workflow.
- This submit button has a conditional to display if it can be clickable. Three different fields have to be filled out on the data type in order for this button to be clickable.
- If a date field called “submitted on” is filled, it will be unclickable regardless of other conditions.
- Once clicked, it runs a backend workflow to send an email, schedule a future email, and make changes to the data type, adding the date submitted on and the scheduled workflow api id.
- This takes a second or two, and I don’t want the user to be able to double click the button and run that workflow a second time. My solution was to create a custom state called “submitted” on the button, a yes/no field, and to change the CS to yes when the button is clicked, adding a condition to make the button unclickable when the CS is yes.
- At the end of the workflow, I would change the CS back to no, and by that point, the date field submitted on would be filled, so the button would remain unclickable.
Seemed simple enough to me. I have a WF that starts by:
- Setting the CS to yes
- Display an alert that action succeeded
- Schedule an API WF
- Set the CS back to no, using the boolean statement “Result of step 3 is empty” (which should allows result in a “no” since it should return the API WF id) to set the CS value.
My thinking was that the button should remain unclickable once it was clicked. But to my surprise, it went back and forth between unclickable, to clickable, then to unclickable. It seems the WF CS set to yes comes first, then somehow the WF CS set to no kicks in making it clickable again, and when the API WF finishes (setting the date field submitted on) it then goes back to unclickable.
I also reconfigured it to run two custom events in sequence.
- Set CS to yes
- Display alert
- CE to schedule the API call
- CE to set the CS value back to no
Yet it still had the same result of going back and forth.
I could just set the “submitted on date” right away, which would nip this in the bud early, but I’m trying to understand how come I couldn’t get the order to run properly here. What am I not seeing?