Dropdown write value scripting

I have a dropdown component which contains a few options.

1- Empty
2- Break
3- Wet
4- Dry

The selected value is connected to an Ignition OPC tag via a binding. I want this to be bi-directional. The PLC value can update the dropdown, and a user selection will write to the PLC tag.

I have currently set up a script which is triggered by the dropdown propertyChange event, filtering by

if event.propertyName == "selectedValue"

I then write to my tag with

system.tag.write(tagPath, event.newValue)

The issue i am having is that i can’t seem to distinguish between a USER selection change and a PLC tag change. The script is being fired on BOTH events.

I have two questions:

  1. Is there a way to distinguish the two events so that i only execute the write tag script when the USER has changed the selected value?

  2. Is there a way to prevent the script running on first load of the popup that contains these dropdowns so that the PLC tag value isn’t written to initially?

Add a custom property to the dropdown and bind that to the tag (unidirectionally). Then bind selectedValue to the custom property, again, unidirectionally. Then, in the propertyChange event, after checking that it is for the selectedValue property, compare the new selectedValue against the current value of the custom property. If they already match, omit the tag write.

:prayer: Brilliant idea, worked a treat. So simple I completely overlooked it. Was trying to over-complicate things with horrible scripts. Thanks!

With this current setup, why would the propertyEvent script not fire for “selectedValue” or “currentValue” (custom property) when the PLC writes to the tag?
The values change and i can see the dropdown change, but no event script is fired?
The event scripts only fire when the operator makes a change via Ignition.
Just revising it again because i’m trying to prevent the PLC writing 0 to it, but can’t capture that event.

The whole point of the “check selectedValue against the custom property” is to ignore PLC writes. Add a separate section to your propertyChange event looking for value changes on the custom property, without any other cross-check.