# How do I prevent a tag change script from executing when a project is saved?

**URL:** <https://forum.inductiveautomation.com/t/how-do-i-prevent-a-tag-change-script-from-executing-when-a-project-is-saved/92354>\
**Category:** Ignition\
**Tags:** ignition81, vision\
**Created:** [June 25, 2024, 5:54pm UTC](https://forum.inductiveautomation.com/t/how-do-i-prevent-a-tag-change-script-from-executing-when-a-project-is-saved/92354 "2024-06-25T17:54:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sherman](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@sherman](https://forum.inductiveautomation.com/u/sherman)\
**Post date:** [June 25, 2024, 5:54pm UTC](https://forum.inductiveautomation.com/t/how-do-i-prevent-a-tag-change-script-from-executing-when-a-project-is-saved/92354/1 "2024-06-25T17:54:30Z")

</div>

I have tag change scripts that are emitting MQTT messages when their values change (not quality, not timestamp). When I save the project holding the Gateway Tag Change Scripts, it seems to trigger this script for evey tag path that is being triggered. This is dealbreaking behavior, I have to make this not happen. Does anyone know how to prevent this behavior? The value of these tags are **not** changing when I save the script. I think the system does something like preloads its tag value cache to None or Null or whatever and then goes through an update phase, but I can't prove it.

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [June 25, 2024, 5:57pm UTC](https://forum.inductiveautomation.com/t/how-do-i-prevent-a-tag-change-script-from-executing-when-a-project-is-saved/92354/2 "2024-06-25T17:57:24Z")

</div>

Typically, this is prevented by adding

```python
if not initialChange:
    ...

```

---

<div class="post-metadata">

**Author:** ![sherman](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@sherman](https://forum.inductiveautomation.com/u/sherman)\
**Post date:** [June 25, 2024, 5:59pm UTC](https://forum.inductiveautomation.com/t/how-do-i-prevent-a-tag-change-script-from-executing-when-a-project-is-saved/92354/3 "2024-06-25T17:59:37Z")

</div>

Thanks, I was trying

```python
if executionCount <= 1:
    pass

```

which was not working. I totally missed that line above it in the documentation!

---

<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:** [June 25, 2024, 6:16pm UTC](https://forum.inductiveautomation.com/t/how-do-i-prevent-a-tag-change-script-from-executing-when-a-project-is-saved/92354/4 "2024-06-25T18:16:29Z")

</div>

It is important that you actually **handle** the `initialChange` case for something like this, as that initial change _ **CAN** _ be a new value. There is a small window during scripting restart where a real change can be dropped into the void, along with the obviously larger time windows involving project enable/disable and actual gateway restarts.

For really critical systems, you need to maintain your **own** persistence mechanism (database, external files, whatever) tracking the origins, values, and timestamps that you have actually passed on to the next system.

---

<div class="post-metadata">

**Author:** ![sherman](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@sherman](https://forum.inductiveautomation.com/u/sherman)\
**Post date:** [June 25, 2024, 6:36pm UTC](https://forum.inductiveautomation.com/t/how-do-i-prevent-a-tag-change-script-from-executing-when-a-project-is-saved/92354/5 "2024-06-25T18:36:10Z")

</div>

I am using this system for emitting requests for external information or action -- in this particular case I'd rather nothing was sent than something was erroneously sent. There shouldn't be a circumstance where when the project is reloaded that I want anything to be emitted.
