I created Top branch first and then Bottom branch. As expected after pressing the button the text was “Bottom branch”
After visually switching places of both modules. The result was the same. “Bottom branch” even though visually it was on the top. So the flow execution order does not take visual placement - which make sense - it could get trickingy in some cases.
Next step I have disconnected “Top branch” (techically at the bottom now) and connected it again. After saving and test result was “Top branch” - great we changed the order.
-However after any modification to the flow e.g. attachingToast module to “Bottom module” (technically on top on my screenshot) - the flow has reversed to original order.
What I can figure out is that the execution order follows the order of creation? It might be possible to change it , but there are more factors at hand.
Now we disconnect “First branch”, save, connect the “First branch” again.
Save, execute. “First branch” gets executed second.
This would make a lot of sense, but from testing, any change to component logic (even attached to a different button) and Save, reverts to original order of execution, “Second branch” becomes executed as second.
This is an isolated simple scenario, but with more logic components connected it would be good to know the order rules.
@Greg_F, yeah, as you see in your tests, the order of the execution in this case cannot be trusted, unfortunately. This is because of the asynchronous nature of the logic flow functions.
In this case, when you have two very simple “set variable” functions, this might feel confusing, and I agree with you with that. However, let’s assume that you are using some other flow functions, e.g. “Get record”, that load data from Internet. When in parallel like this, these two requests will indeed be executed concurrently, in parallel, which is a good thing for performance! However, you can never be sure which one completes first! This depends on many factors such as network, server loads, etc.
I’d summarize it like this: when you have two flow functions in parallel, you should never make assumptions about their completion order! Even in this case with two “set variable” flow functions!
Instead, as a rule of thumb, I personally recommend you to always put the flow functions in sequence when their completion order matters!
Hopefully this clarified things a little bit! So, the answer to your question “which one is executed first” is “it is uncertain” and the reason for that is because flow functions are asynchronous!
This is a perfectly clear answer! Very good to know.
This way if parallel is really necessary, it could be solved by building a delay and if check for a result of other branch, but this starts getting tricky. As you say following sequential order might be best choice.
As a side node: we are aware that managing parallel flows is quite difficult right now. For example: execute two server requests in parallel and wait for them both to complete, and only after that continue the flow. Currently you could use e.g. page variables to store some state of the execution flows, but we have visions for features that could make creating such flows much easier in the future.