# Can a second copy of a script be started before the original copy completes?

**URL:** <https://forum.inductiveautomation.com/t/can-a-second-copy-of-a-script-be-started-before-the-original-copy-completes/100972>\
**Category:** Ignition\
**Created:** [January 16, 2025, 3:04pm UTC](https://forum.inductiveautomation.com/t/can-a-second-copy-of-a-script-be-started-before-the-original-copy-completes/100972 "2025-01-16T15:04:03Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robert\_Reed](https://avatars.discourse-cdn.com/v4/letter/r/43a26b/32.png) [@Robert\_Reed](https://forum.inductiveautomation.com/u/Robert_Reed)\
**Post date:** [January 16, 2025, 3:04pm UTC](https://forum.inductiveautomation.com/t/can-a-second-copy-of-a-script-be-started-before-the-original-copy-completes/100972/1 "2025-01-16T15:04:03Z")

</div>

I have a script that is triggered by the handshake tag coming from a Transaction group. The script gathers data, triggers the Transaction group again and then does some housekeeping.

It loops thru this process until all data has been processed.

What I want to know is what would happen if the trigger tag for a script is set while the script is running.

Would a second instance of the script be started before the original instance completes?

---

<div class="post-metadata">

**Author:** ![Programmatic](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/programmatic/32/70979_2.png) [@Programmatic](https://forum.inductiveautomation.com/u/Programmatic)\
**Post date:** [January 16, 2025, 3:06pm UTC](https://forum.inductiveautomation.com/t/can-a-second-copy-of-a-script-be-started-before-the-original-copy-completes/100972/2 "2025-01-16T15:06:49Z")

</div>

I believe this is possible. You can check the running scripts section of the gateway and test it to see.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/c/5c298506046518f5b3b60e72d86d0995d6a7caf3.png)

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [January 16, 2025, 3:08pm UTC](https://forum.inductiveautomation.com/t/can-a-second-copy-of-a-script-be-started-before-the-original-copy-completes/100972/3 "2025-01-16T15:08:38Z")

</div>

What mechanism are you using to run the script? Tag event script? Gateway tag change script? Something else?

---

<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:** [January 16, 2025, 3:21pm UTC](https://forum.inductiveautomation.com/t/can-a-second-copy-of-a-script-be-started-before-the-original-copy-completes/100972/4 "2025-01-16T15:21:32Z")

</div>

> [@Robert\_Reed](#):
>
> Would a second instance of the script be started before the original instance completes?

Not for the same tag, nor for any tags in the **same** gateway tag change event.

---

<div class="post-metadata">

**Author:** ![Robert\_Reed](https://avatars.discourse-cdn.com/v4/letter/r/43a26b/32.png) [@Robert\_Reed](https://forum.inductiveautomation.com/u/Robert_Reed)\
**Post date:** [January 16, 2025, 3:34pm UTC](https://forum.inductiveautomation.com/t/can-a-second-copy-of-a-script-be-started-before-the-original-copy-completes/100972/5 "2025-01-16T15:34:14Z")

</div>

I am triggering the script with a tag event, with the tag being the handshake tag from the Transaction Group.

---

<div class="post-metadata">

**Author:** ![Robert\_Reed](https://avatars.discourse-cdn.com/v4/letter/r/43a26b/32.png) [@Robert\_Reed](https://forum.inductiveautomation.com/u/Robert_Reed)\
**Post date:** [January 16, 2025, 3:36pm UTC](https://forum.inductiveautomation.com/t/can-a-second-copy-of-a-script-be-started-before-the-original-copy-completes/100972/6 "2025-01-16T15:36:50Z")

</div>

Correction- I am triggering the script with a gateway event tag change script.

---

<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:** [January 16, 2025, 3:38pm UTC](https://forum.inductiveautomation.com/t/can-a-second-copy-of-a-script-be-started-before-the-original-copy-completes/100972/7 "2025-01-16T15:38:46Z")

</div>

So, no. It will not trigger in parallel. However, there's nothing in the scripting subsystem that will keep the transaction group from running again, and that will **queue** a tag change event to be processed when the running event finishes.

In cases where I need scripting to participate in a process, I move the entire transaction group's functionality to the script. Trigger the whole script with the TG's original trigger, not with any TG completion tag.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [January 16, 2025, 3:39pm UTC](https://forum.inductiveautomation.com/t/can-a-second-copy-of-a-script-be-started-before-the-original-copy-completes/100972/8 "2025-01-16T15:39:01Z")

</div>

What Phil just said.

---

<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:** [January 16, 2025, 3:49pm UTC](https://forum.inductiveautomation.com/t/can-a-second-copy-of-a-script-be-started-before-the-original-copy-completes/100972/9 "2025-01-16T15:49:13Z")

</div>

Basic procedure to use if converting a TG to a script:

> [@AWT-EventQueue-0 Problems](https://forum.inductiveautomation.com/t/awt-eventqueue-0-problems/80128/6):
>
> Any transaction group that records to a DB can be replaced by a script that performs the following: Call system.tag.readBlocking() with a list of needed tags, and/or call system.opc.readValues() with a list of needed OPC Items (or both), Perform any arithmetic necessary for expression items using the above values, Execute system.db.runPrepUpdate() call to INSERT or UPDATE into the database, Perform any writes to handshake tag(s), if applicable. (Many more possibilities than the simp…

---

<div class="post-metadata">

**Author:** ![Robert\_Reed](https://avatars.discourse-cdn.com/v4/letter/r/43a26b/32.png) [@Robert\_Reed](https://forum.inductiveautomation.com/u/Robert_Reed)\
**Post date:** [January 16, 2025, 4:00pm UTC](https://forum.inductiveautomation.com/t/can-a-second-copy-of-a-script-be-started-before-the-original-copy-completes/100972/10 "2025-01-16T16:00:09Z")

</div>

Thanks for the feedback. I am glad that I do not have top worry about simultaneous execution of the same script.  
I am using an integer as the trigger to the transaction group, incrementing it's value by 1 for each execution, with the stored procedure Transaction group set to execute once while trigger is active. It works very well.
