# Won't Write Script Before Navigation

**URL:** <https://forum.inductiveautomation.com/t/wont-write-script-before-navigation/89455>\
**Category:** Ignition\
**Tags:** scripting, perspective\
**Created:** [April 25, 2024, 2:44pm UTC](https://forum.inductiveautomation.com/t/wont-write-script-before-navigation/89455 "2024-04-25T14:44:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Reid\_Clark](https://avatars.discourse-cdn.com/v4/letter/r/85f322/32.png) [@Reid\_Clark](https://forum.inductiveautomation.com/u/Reid_Clark)\
**Post date:** [April 25, 2024, 2:44pm UTC](https://forum.inductiveautomation.com/t/wont-write-script-before-navigation/89455/1 "2024-04-25T14:44:31Z")

</div>

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?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/6/e63a1b55dfd79640b28e3e43fb44fb73a4e6c3e5.png)

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [April 25, 2024, 2:48pm UTC](https://forum.inductiveautomation.com/t/wont-write-script-before-navigation/89455/2 "2024-04-25T14:48:00Z")

</div>

The Organize Actions are carried out asynchronously.

- Delete the Navigation action.
- Use [system.perspective.navigate | Ignition User Manual](https://docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-perspective/system-perspective-navigate) in your script.

Now you are back in control.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [April 25, 2024, 2:48pm UTC](https://forum.inductiveautomation.com/t/wont-write-script-before-navigation/89455/3 "2024-04-25T14:48:11Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Reid\_Clark1](https://avatars.discourse-cdn.com/v4/letter/r/f04885/32.png) [@Reid\_Clark1](https://forum.inductiveautomation.com/u/Reid_Clark1)\
**Post date:** [April 25, 2024, 3:23pm UTC](https://forum.inductiveautomation.com/t/wont-write-script-before-navigation/89455/4 "2024-04-25T15:23:32Z")

</div>

Ahhh thank you!

---

<div class="post-metadata">

**Author:** ![DaveRNeal](https://avatars.discourse-cdn.com/v4/letter/d/53a042/32.png) [@DaveRNeal](https://forum.inductiveautomation.com/u/DaveRNeal)\
**Post date:** [August 13, 2024, 4:25pm UTC](https://forum.inductiveautomation.com/t/wont-write-script-before-navigation/89455/5 "2024-08-13T16:25:08Z")

</div>

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](https://www.docs.inductiveautomation.com/docs/8.1/ignition-modules/perspective/working-with-perspective-components/component-events-and-actions):

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

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 13, 2024, 4:34pm UTC](https://forum.inductiveautomation.com/t/wont-write-script-before-navigation/89455/6 "2024-08-13T16:34:43Z")

</div>

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** _.
