How things work - how actions actually execute when perspective button is pressed?

hi
I am using 8.1.20 with perspective. Really simple scenario - i press a button and there are 2 actions behind the button - script to call message handler and second action is a popup type of action to close the popup - please see the screenshot.
I was surprised that 2nd action (closing popup) interfered with calling action 1 and message handler. It was fixed by using only 1 script action and closing the popup inside the script.
How does the code actually execute - is it not sequential so action 2 should execute only after action 1 or are both called asynchronously?

@pturmel any chance for your insight as well?

https://docs.inductiveautomation.com/display/DOC81/Component+Events+and+Actions#ComponentEventsandActions-ActionTypes

" Each Action is called in order from top to bottom. To control this execution order, you can reorder the list of Actions using the Up Arrow and Down Arrow icons next to the list. However, Actions are not executed synchronously: sequential actions do not wait for any prior Actions to finish executing before running. Thus, if Action 1 is a long-running script, while Action 2 is quick to finish, it is possible that Action 2 will finish before Action 1."

5 Likes

Common mistake. Actions are started in order, but run in parallel. The popup close operation happens on the front end basically simultaneous with the message to the gateway to run the script, and is accompanied by the message that the popup is now closed. Running a script has substantial startup overhead, so the gateway processes the "popup closed" message faster, and the popup closed state then prevents the script startup from completing.

It has worked like this from day one, and is not considered a bug. Separate actions are not allowed to depend on each other. Where there's any dependency, you must use a single script to make things happen in the desired order.

6 Likes

great explanation which gives me an insight to how internals work and adds to by knowledge base