# Issue of TagChangeScripts when switching to the backup server

**URL:** <https://forum.inductiveautomation.com/t/issue-of-tagchangescripts-when-switching-to-the-backup-server/92833>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [July 5, 2024, 10:11am UTC](https://forum.inductiveautomation.com/t/issue-of-tagchangescripts-when-switching-to-the-backup-server/92833 "2024-07-05T10:11:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ethan\_Carter](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ethan_carter/32/60139_2.png) [@Ethan\_Carter](https://forum.inductiveautomation.com/u/Ethan_Carter)\
**Post date:** [July 5, 2024, 10:11am UTC](https://forum.inductiveautomation.com/t/issue-of-tagchangescripts-when-switching-to-the-backup-server/92833/1 "2024-07-05T10:11:37Z")

</div>

To prevent TagChangeScripts from triggering during startup or when saving a project, we added 'if not initialChange' at the top.  
However, we noticed that when switching to the backup server, the scripts do not run correctly when the first time tag changed, but then they work fine afterward.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/6/46d51a87557236c17a758364eb79ea47b7be65e6.png)  
Right after switching to the backup server, the 'Last Execution' for all scripts shows as 'Never'. We suspect that when switching to the backup machine, the first trigger is being treated as 'initialChange'.  
Is there anyway to avoid this issue?Thanks.

---

<div class="post-metadata">

**Author:** ![Ethan\_Carter](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ethan_carter/32/60139_2.png) [@Ethan\_Carter](https://forum.inductiveautomation.com/u/Ethan_Carter)\
**Post date:** [July 5, 2024, 10:12am UTC](https://forum.inductiveautomation.com/t/issue-of-tagchangescripts-when-switching-to-the-backup-server/92833/2 "2024-07-05T10:12:21Z")

</div>

By the way, we are using version 8.1.37.

---

<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:** [July 5, 2024, 1:47pm UTC](https://forum.inductiveautomation.com/t/issue-of-tagchangescripts-when-switching-to-the-backup-server/92833/3 "2024-07-05T13:47:41Z")

</div>

The whole point of running the events with the `initialChange` flag is to signal to your logic a "dead spot" in Ignition's knowledge of valid changes. The "dead spot" could be just a few milliseconds (project edits), or several seconds (redundancy failover), or minutes or hours (restarts and long shutdowns).

The value supplied when `initialChange` is true **can be** an actual change--you cannot just discard them. When recording based on changes, and when initial change is true, you must consult your recordings to determine what the last handled value was, then do your normal logic if a real change.

---

<div class="post-metadata">

**Author:** ![Ethan\_Carter](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ethan_carter/32/60139_2.png) [@Ethan\_Carter](https://forum.inductiveautomation.com/u/Ethan_Carter)\
**Post date:** [July 5, 2024, 3:54pm UTC](https://forum.inductiveautomation.com/t/issue-of-tagchangescripts-when-switching-to-the-backup-server/92833/4 "2024-07-05T15:54:28Z")

</div>

Thank you for your reply. We have tried the following method and it seems to be effective, but is there a better way?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/9/49185466e04f1e616d48577dd2c1e39703c6fdbf.png)

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

---

<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:** [July 5, 2024, 4:21pm UTC](https://forum.inductiveautomation.com/t/issue-of-tagchangescripts-when-switching-to-the-backup-server/92833/5 "2024-07-05T16:21:06Z")

</div>

There's no **generic** better way, as the technique needed to verify completed prior operations is entirely dependent on your application. Checking current versus previous values like shown only handles unexpected quality changes (from failover, presumably). It won't handle true changes coming in a dead spot.

---

<div class="post-metadata">

**Author:** ![Ethan\_Carter](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ethan_carter/32/60139_2.png) [@Ethan\_Carter](https://forum.inductiveautomation.com/u/Ethan_Carter)\
**Post date:** [July 9, 2024, 2:51am UTC](https://forum.inductiveautomation.com/t/issue-of-tagchangescripts-when-switching-to-the-backup-server/92833/6 "2024-07-09T02:51:32Z")

</div>

Let's set aside the issue of dead spots for now.  
During gateway startup or save, all scripts within Gateway Events are executed. Is there a way to trigger the same operations when the master switches to the backup?

---

<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:** [July 9, 2024, 11:52am UTC](https://forum.inductiveautomation.com/t/issue-of-tagchangescripts-when-switching-to-the-backup-server/92833/7 "2024-07-09T11:52:45Z")

</div>

I don't think so.
