Ignition Edge Project Script Value or Quality Script not Firing

Context: I have a script which fires on value (or quality) change that searches a dictionary of integers and looks up an associated engineering unit (and writes to .EngUnit). The ignition edge instance pulls the integer in over OPC UA.

Problem: In the development phase of the project (using trials), I expect that resetting the trial causes a re-connection to the OPC UA Server, to update the Quality of the tag, however, re-connection often does not trigger the script. When I apply the same script with no update, the script executes as expected.

Is there a better way to execute this type of script where either a value change or quality change, is expected to fire the script?

Seems odd to me that you'd be scripting an EU change. Does the EU change on the fly? If so, what value(s) determine the EU? Sounds like a job for an expression string to me, rather than using the included tag EU property.

What does your script look like? Does it check for initial change?

Thank you for the contribution, the EU typically does not typically change on the fly but could change throughout project configuration and also commissioning. As the value is being read from a DCS, there can be differences amongst equipment, so this is one way to pull the integer from the control system and use a lookup table to place the EU into a consistent location.

The script uses the built-in Value Events/Value Changed Script type.
The script then builds the path in the DCS to read the integer.
The script then calls the lookup table (python dictionary) to convert the integer into a string (via calling a project script/function)
The value from the project script is passed to the tag script and writeBlocking is used to write the value to the EngUnit property.

Write the engineering unit description back to the custom tag property 'engUnit'

if engUnitDescription is not None:
	system.tag.writeBlocking([tagPathStr + ".EngUnit"], [engUnitDescription])
else:
	system.tag.writeBlocking([tagPathStr + ".EngUnit"], ["No Value"])

Each step of the script is logged.

When restarting an OPC Connection after a trial the value observed on some tags is "No Value", while others are the expected output of the lookup table. All possible integer values currently exist in the python dictionary so "No Value" should never be the output unless possibly on loss of connection to the OPC Server if the last value of the tag is somehow lost and the script were to then execute.

The script should almost certainly be a Gateway Tag Change Event. Where it should delegate to a Project Library Script. The "lookup" dictionary should be a Top Level Variable in the Project Library.

I'd venture to guess that the initial change or bad quality causes a momentary value of Null for your engUnitDescription.

Add a check for bad quality and/or initial change.

When you say None do you actually mean none? Would a blank character string work for your use case?

if engUnitDescription is not None:

can be interpreted as if the dictionary lookup doesn't find a value it will return the value "None" to the function. This could be any value and "" could work. I will attempt to apply checks for bad quality and initial change and write back.

It returns the string literal "None" or the python keyword None? Very big difference.