# Event Actions executing before previous one is complete

**URL:** <https://forum.inductiveautomation.com/t/event-actions-executing-before-previous-one-is-complete/24808>\
**Category:** Ignition Early Access\
**Tags:** ignition80\
**Created:** [May 8, 2019, 7:14pm UTC](https://forum.inductiveautomation.com/t/event-actions-executing-before-previous-one-is-complete/24808 "2019-05-08T19:14:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![grietveld](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/grietveld/32/6984_2.png) [@grietveld](https://forum.inductiveautomation.com/u/grietveld)\
**Post date:** [May 8, 2019, 7:14pm UTC](https://forum.inductiveautomation.com/t/event-actions-executing-before-previous-one-is-complete/24808/1 "2019-05-08T19:14:00Z")

</div>

I’m not sure if a bug, or if I just need to change how I’m doing this, but if I have a script, followed by an action to close the popup, the script doesn’t finish executing before the window closes.

Is there a way to make this execute in order and not close until the previous step is completed?

![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/3/366ab005381a80c5ba4b81230dbbd37624a937b7.png)

---

<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:** [May 8, 2019, 7:26pm UTC](https://forum.inductiveautomation.com/t/event-actions-executing-before-previous-one-is-complete/24808/2 "2019-05-08T19:26:02Z")

</div>

You’re not missing anything, although it’s not a bug - this is just part of the way actions work. Actions _are_ executed in order, but script actions are invoked asynchronously on the gateway. We do have plans to add UI to make this more clear, but since scripts run on the gateway (by necessity) the script action that happens is just the invocation message being sent to the gateway. There’s no guarantee that it will happen before the next action does (in fact, you can pretty much guarantee _it won’t_) – the script might take an extremely long time, or never return, or throw all kinds of errors.

---

<div class="post-metadata">

**Author:** ![grietveld](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/grietveld/32/6984_2.png) [@grietveld](https://forum.inductiveautomation.com/u/grietveld)\
**Post date:** [May 8, 2019, 7:29pm UTC](https://forum.inductiveautomation.com/t/event-actions-executing-before-previous-one-is-complete/24808/3 "2019-05-08T19:29:13Z")

</div>

Alright, I’ll move the close popup action into my script then, that should at least resolve the issue in this case.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [May 8, 2019, 8:51pm UTC](https://forum.inductiveautomation.com/t/event-actions-executing-before-previous-one-is-complete/24808/4 "2019-05-08T20:51:25Z")

</div>

If you have an event which requires that a Script Action be utilized, and you want things to happen IN ORDER, then yes, you should include all Actions you would like to execute in order in the Script Action. We worked hard to make sure that there were equivalent scripting methods in place for all Actions for precisely this reason.
