Property Change Script Runs on Project Save

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.

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.

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.

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.

1 Like

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

1 Like

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