Won't Write Script Before Navigation

I am trying to use a button to first write to multiple tags (currently just one in the script for testing) then navigate away from the screen using onActionPerformed. If I disable the navigation, the script works and the tags are written too. If I enable the navigation, the tags aren't written but the navigation does happen. I have the script as number 1 and the navigation as number 2. Is there something I'm missing?

The Organize Actions are carried out asynchronously.

Now you are back in control.

1 Like

Actions are ordered, but not blocking. And script actions require a round trip to the gateway, so they're always slower than actions that can run in the browser.

Put both/all "things to do" in one script action if you need any script action.

3 Likes

Ahhh thank you!

This problem bit me earlier today, I thought there was an error in my script that was preventing some simple system.perspective.print() calls from writing to my console, only to realize that it was navigating away before the script was complete. From the documentation:

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.

The documentation understates the situation for some cases. Navigation it typically local to the browser, so if that is your "Action 2", the documentation should say:

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 starts.

2 Likes