# Property Change Script Runs on Project Save

**URL:** <https://forum.inductiveautomation.com/t/property-change-script-runs-on-project-save/72198>\
**Category:** Ignition\
**Tags:** perspective, ignition81\
**Created:** [April 7, 2023, 7:55pm UTC](https://forum.inductiveautomation.com/t/property-change-script-runs-on-project-save/72198 "2023-04-07T19:55:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_Wade](https://avatars.discourse-cdn.com/v4/letter/d/3e96dc/32.png) [@Daniel\_Wade](https://forum.inductiveautomation.com/u/Daniel_Wade)\
**Post date:** [April 7, 2023, 7:55pm UTC](https://forum.inductiveautomation.com/t/property-change-script-runs-on-project-save/72198/1 "2023-04-07T19:55:22Z")

</div>

Hello, I have a property change script on a custom property that I'm using to trigger a named query that inserts a new record into a DB. The problem is, every time I save the project, the script is ran and I get 20+ new records in my DB. Unlike the tag change script, property scripts do not have the "initialChange" parameter to reference. I've tried the currentValue != previousValue, but that doesn't work either.

---

<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:** [April 7, 2023, 9:28pm UTC](https://forum.inductiveautomation.com/t/property-change-script-runs-on-project-save/72198/2 "2023-04-07T21:28:38Z")

</div>

Seems fragile anyways--properties in the UI get initialized every time the corresponding object opens, and the infra has no real way to distinguish the origin of a chain of bindings. What action writes to the property to trigger the **desired** behavior? Consider moving the NQ call to that.

---

<div class="post-metadata">

**Author:** ![Daniel\_Wade](https://avatars.discourse-cdn.com/v4/letter/d/3e96dc/32.png) [@Daniel\_Wade](https://forum.inductiveautomation.com/u/Daniel_Wade)\
**Post date:** [April 10, 2023, 12:59pm UTC](https://forum.inductiveautomation.com/t/property-change-script-runs-on-project-save/72198/3 "2023-04-10T12:59:43Z")

</div>

Here is some more details to what I am doing. We have several offsite Edge gateways reporting data via MQTT and JSON. We'll just say these are motors and conveyors that we are monitoring. I have flex repeaters that I fill using a script that allows me to assign the JSON data to each repeated view individually. This is done by assigning variables for the tag path. We end up with each of the components having a tag path to their JSON data. I'm then parsing out the status of each component and on a value change, I write to the DB (as described above). This is to act like a task history so we can look back to see when devices change state.

It is not a good idea to set these up on the tags themselves because the Edge deployment is generic (a lot of unused tags) and it would be difficult to add these every time we add a new remote Edge gateway.

Other than it triggering during a save, this seems to be working well.

---

<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:** [April 10, 2023, 1:11pm UTC](https://forum.inductiveautomation.com/t/property-change-script-runs-on-project-save/72198/4 "2023-04-10T13:11:13Z")

</div>

OK, even more fragile that I thought. What happens if two clients open that same view? Duplicate database entries? And what happens if no client is open to that view?

Data processing in the system needs to be in gateway scope to be reliable, not in a UI, except where the UI is providing information to the process.

---

<div class="post-metadata">

**Author:** ![Daniel\_Wade](https://avatars.discourse-cdn.com/v4/letter/d/3e96dc/32.png) [@Daniel\_Wade](https://forum.inductiveautomation.com/u/Daniel_Wade)\
**Post date:** [April 10, 2023, 1:21pm UTC](https://forum.inductiveautomation.com/t/property-change-script-runs-on-project-save/72198/5 "2023-04-10T13:21:50Z")

</div>

So what is the recommendation here? Run a gateway script that monitors for a change?

---

<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:** [April 10, 2023, 1:48pm UTC](https://forum.inductiveautomation.com/t/property-change-script-runs-on-project-save/72198/6 "2023-04-10T13:48:56Z")

</div>

> [@Daniel\_Wade](#):
>
> Run a gateway script that monitors for a change?

Yes, or a gateway timer script that examines the PLC state and produces your supplemental state on a desired pace.
