Error executing script for event: propertChange on component: Text

I was working with Inductive Automation support, but they lost patience and stop responding.

I want to enter a string value in the bottom text field (“Material_Tag_Input_9”), hit enter and have that same value appear in the top text field (“Material_Tag_Input_8”). These tags lie in a connected PLC.

In the attached picture pic 3, I have the following scripting for a propertyChange event handler:

if event.propertyName == ‘text’:
Material8 = system.tag.readBlocking([’[default]D17_11319/Material_Tag_Input_8_’]).value
system.tag.writeBlocking([’[default]D17_11319/Material_Tag_Input_9_’], [Material8])

When I type the string into the bottom text field (“Material_Tag_Input_8_”) and hit enter, I get the errors as seen in pic 1 and pic 2.

I’m having difficulty trying to figure out what’s wrong, can anyone help?

Your readBlocking call returns a list, not a scalar value.

It should look something like this:

Material8 = system.tag.readBlocking(["whatever"])[0].value

Thanks for the response Kevin. This eliminated the errors, but when I type the string and hit enter in the bottom text field (“Material_Tag_Input_9_”) the string isn’t reflecting in the top text field (“Material_Tag_Input_8”). I only have the scripting in the bottom text field.

Nothing looks wrong and it works for me in a little test setup.

Can you write to the target OPC tag at all? Through the tag browser maybe?

I tried doing it through the Tag Browser for the “Material_Tag_Input_9” text field, it changes to what I type in the tag browser and the text field reflects the change momentarily, then it reverts back what I have in the “Material_Tag_Input_8” text field

Since that’s an OPC tag the most likely explanation is that the PLC it’s from is overwriting the value or ignoring the write.

Also I’ll note that this reflects in the PLC momentarily as well before it reverts back. There is no active logic tied to the “Material_Tag_Input_9_” so the PLC isn’t forcing the value back to what was in “Material_Tag_Input_8_”

If it’s not the PLC logic reverting it then you have a binding or other scripting doing it.

Ok, so this is what I found.

When I type something (i.e. Kevin) in “Material_Tag_Input_8” (the top box), and THEN when I try to type “Herron” in “Material_Tag_Input_9” and hit enter, it says Herron momentarily then comes back as Kevin.

Maybe I got the tags swapped in the scripting??

if event.propertyName == ‘text’:
Material8 = system.tag.readBlocking([’[default]D17_11319/Material_Tag_Input_8_’])[0].value
system.tag.writeBlocking([’[default]D17_11319/Material_Tag_Input_9_’], [Material8])

I guess I’m a little confused.

If you want the value to appear in the top text field why not just write to the text property of that component directly?

Is either text field configured with a binding? This sounds exactly like a race condition where you have something writing to the same value from two different directions.

Understanding more about how you have these text fields configured or what your are trying to accomplish would allow us to better help


The script is doing exactly what you’re telling it to do. I’ve added comments to your code below:

# If the text value of Material_Tag_Input_9 component (lower text box) changes, then...
if event.propertyName == 'text':
	# Read the value of the tag connected to Material_Tag_Input_8 (top box), and...
	Material8 = system.tag.readBlocking(['[default]D17_11319/Material_Tag_Input_8_'])[0].value
	# Write that value to the tag connected to Material_Tag_Input_9 (bottom box).
	system.tag.writeBlocking(['[default]D17_11319/Material_Tag_Input_9_'], [Material8])

The lower box shows “Herron” for a moment after you type it because you just entered that value. But then the property change script is triggered by that value change and does what you’ve told it to, overwriting your entry with “Kevin” from the first text box.

If you want it to overwrite the top text box with the value from the bottom text box, you could swap the read and write tag addresses. Or–more efficient–just write it directly to the upper text box as @lrose suggests–something like below, substituting the upper text box’s component path in place of pathToUpperTextBox:

# Code in lower text box that executes when its text value changes:
if event.propertyName == 'text':
	# Write the new value from lower text box to upper text box.
	pathToUpperTextBox.text = event.newValue

To expand on @witman’s and @lrose’s posts, and judging by the binding icons in your second post, the race condition exists because bindings work asynchronously to the script. The old value is being read from the tag through the script before the new value is written to it by the binding.

Assuming the bindings are both bidirectional (the default setting) then the script suggestion by @witman will work, as the bindings will update the tags’ values.

If there’s is something specific you’re trying to do, please let us know. Our answers usually get better that way. :wink:


Sorry for the late response. Thanks for the suggestions everyone! Of course the scope of this project has been changed so the requests I was making are now null and void. But now I have a new set of challenges since the scope has changed which will likely involve some python programming. I’ll make sure to seek guidance for when I begin trying to tackle to the new obstacles. Thanks again everyone!

1 Like