How to make sure workflows run in order after each other - I have subsequently triggered custom events only

Hello guys,

I am developing a huge and complex calculation-app.

In the final step I am calculating many values that depend on each other. So this means that it is very important that each next calculation is triggered after the one before has finished because the result is needed to proceed to the next calculation.

I am in contact with the support but they don’t help at all. The recommendation was to add a pause of 2 seconds and the side info that the debugger has major flaws. Alright fine but this is not helping my problem.

I have read the documentation telling about paralell fired workflows - therefore I have now packed everything in custom events. But the behavior is still the same:

Some values are completely empty and some are wrong. This is due to the fact that not all values are ready at the time they are needed. This does not make any sense to me since I am working with custom events only and they are supposed to run in sequence mode as far as I understood from the docs or this for example: Tip: Order of Operation - #2 by aschofer

There is also that hint that you can just add the “only when” option with “result of previous step is not empty” but this does not make any sense either because if the value happens to be empty the called custom event will just not fire. There is nothing like a “wait for…” checkbox.

So my current setup is:

I run WF1 triggered by a button click

create a new…calculation
trigger WF2 (with 1 variable: the result of create a new…)

create calculation_wf2
make changes to item (where unique_id is coming from the item delivered by WF1)
trigger WF3 (with 2 variables: the result of the current change and the object of WF1)

create calculation_wf3
make changes to item (where unique_id is coming from the item delivered by WF2)
trigger WF4 (with 3 variables: the result from WF2, the result of the current change and the object of WF1)

…and so on for 15 WFs

When I check the logs I can see WF4 and WF3 first and before WF1 and of course those values are always empty.

I am also writing every step to the console and checking the values which are always 100% correct - also the debugger is 100% correct.

Anybody with any idea how to fix this and make it run in order?

Thank you!

use custom workflow triggers

Why not just do all your intermediate calculations with custom states? You don’t need to make database Things to hold the results of every intermediate calculation. Just hold them in memory using custom states, which are essentially page-level/in-memory variables.

And sequences of Set State are completely synchronous. If you want to see someone (me in this case) faff around with Custom States (and show how they might interact with Create/Make Changes and how plugins may or may not mess this up), see:

1 Like