# Error executing script for event: propertChange on component: Text

**URL:** <https://forum.inductiveautomation.com/t/error-executing-script-for-event-propertchange-on-component-text/44599>\
**Category:** Ignition\
**Created:** [March 17, 2021, 8:59pm UTC](https://forum.inductiveautomation.com/t/error-executing-script-for-event-propertchange-on-component-text/44599 "2021-03-17T20:59:03Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![CCoker1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ccoker1/32/22605_2.png) [@CCoker1](https://forum.inductiveautomation.com/u/CCoker1)\
**Post date:** [March 17, 2021, 8:59pm UTC](https://forum.inductiveautomation.com/t/error-executing-script-for-event-propertchange-on-component-text/44599/1 "2021-03-17T20:59:03Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![CCoker1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ccoker1/32/22605_2.png) [@CCoker1](https://forum.inductiveautomation.com/u/CCoker1)\
**Post date:** [March 17, 2021, 8:59pm UTC](https://forum.inductiveautomation.com/t/error-executing-script-for-event-propertchange-on-component-text/44599/2 "2021-03-17T20:59:40Z")

</div>

![pic1](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/a/aaa8e49e8b9687674ff5f2df3622d4f3b2e5e031.png)

---

<div class="post-metadata">

**Author:** ![CCoker1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ccoker1/32/22605_2.png) [@CCoker1](https://forum.inductiveautomation.com/u/CCoker1)\
**Post date:** [March 17, 2021, 9:00pm UTC](https://forum.inductiveautomation.com/t/error-executing-script-for-event-propertchange-on-component-text/44599/3 "2021-03-17T21:00:06Z")

</div>

![pic2](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/7/d7a0a9c21bf2566344b7cc4a2a123628e8ba3bb4.png)

---

<div class="post-metadata">

**Author:** ![CCoker1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ccoker1/32/22605_2.png) [@CCoker1](https://forum.inductiveautomation.com/u/CCoker1)\
**Post date:** [March 17, 2021, 9:00pm UTC](https://forum.inductiveautomation.com/t/error-executing-script-for-event-propertchange-on-component-text/44599/4 "2021-03-17T21:00:31Z")

</div>

![pic3](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/e/2e6b255092768ea239b12999559a4032e2f5cbf3.png)

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [March 17, 2021, 9:01pm UTC](https://forum.inductiveautomation.com/t/error-executing-script-for-event-propertchange-on-component-text/44599/5 "2021-03-17T21:01:32Z")

</div>

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

It should look something like this:

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

```

---

<div class="post-metadata">

**Author:** ![CCoker1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ccoker1/32/22605_2.png) [@CCoker1](https://forum.inductiveautomation.com/u/CCoker1)\
**Post date:** [March 17, 2021, 9:15pm UTC](https://forum.inductiveautomation.com/t/error-executing-script-for-event-propertchange-on-component-text/44599/6 "2021-03-17T21:15:31Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [March 17, 2021, 9:32pm UTC](https://forum.inductiveautomation.com/t/error-executing-script-for-event-propertchange-on-component-text/44599/7 "2021-03-17T21:32:53Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![CCoker1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ccoker1/32/22605_2.png) [@CCoker1](https://forum.inductiveautomation.com/u/CCoker1)\
**Post date:** [March 17, 2021, 9:36pm UTC](https://forum.inductiveautomation.com/t/error-executing-script-for-event-propertchange-on-component-text/44599/8 "2021-03-17T21:36:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [March 17, 2021, 9:39pm UTC](https://forum.inductiveautomation.com/t/error-executing-script-for-event-propertchange-on-component-text/44599/9 "2021-03-17T21:39:10Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![CCoker1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ccoker1/32/22605_2.png) [@CCoker1](https://forum.inductiveautomation.com/u/CCoker1)\
**Post date:** [March 17, 2021, 9:39pm UTC](https://forum.inductiveautomation.com/t/error-executing-script-for-event-propertchange-on-component-text/44599/10 "2021-03-17T21:39:20Z")

</div>

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\_”

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [March 17, 2021, 9:40pm UTC](https://forum.inductiveautomation.com/t/error-executing-script-for-event-propertchange-on-component-text/44599/11 "2021-03-17T21:40:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![CCoker1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ccoker1/32/22605_2.png) [@CCoker1](https://forum.inductiveautomation.com/u/CCoker1)\
**Post date:** [March 17, 2021, 9:57pm UTC](https://forum.inductiveautomation.com/t/error-executing-script-for-event-propertchange-on-component-text/44599/12 "2021-03-17T21:57:57Z")

</div>

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])

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/c/fc88d8580b0aabb79f622e154f58c874094f244f.png)

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [March 18, 2021, 3:45am UTC](https://forum.inductiveautomation.com/t/error-executing-script-for-event-propertchange-on-component-text/44599/13 "2021-03-18T03:45:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [March 18, 2021, 5:07am UTC](https://forum.inductiveautomation.com/t/error-executing-script-for-event-propertchange-on-component-text/44599/14 "2021-03-18T05:07:43Z")

</div>

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

```python
# 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`:

```python
# 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

```

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [March 18, 2021, 10:02am UTC](https://forum.inductiveautomation.com/t/error-executing-script-for-event-propertchange-on-component-text/44599/15 "2021-03-18T10:02:58Z")

</div>

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. 😉

---

<div class="post-metadata">

**Author:** ![CCoker1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ccoker1/32/22605_2.png) [@CCoker1](https://forum.inductiveautomation.com/u/CCoker1)\
**Post date:** [March 25, 2021, 8:18pm UTC](https://forum.inductiveautomation.com/t/error-executing-script-for-event-propertchange-on-component-text/44599/16 "2021-03-25T20:18:53Z")

</div>

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!
