# Updating a Custom Property in a propertyChange Script

**URL:** <https://forum.inductiveautomation.com/t/updating-a-custom-property-in-a-propertychange-script/106510>\
**Category:** Ignition\
**Created:** [May 21, 2025, 3:19pm UTC](https://forum.inductiveautomation.com/t/updating-a-custom-property-in-a-propertychange-script/106510 "2025-05-21T15:19:47Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![pmo](https://avatars.discourse-cdn.com/v4/letter/p/e480ec/32.png) [@pmo](https://forum.inductiveautomation.com/u/pmo)\
**Post date:** [May 21, 2025, 3:19pm UTC](https://forum.inductiveautomation.com/t/updating-a-custom-property-in-a-propertychange-script/106510/1 "2025-05-21T15:19:47Z")

</div>

I have a custom property named Trigger that I use to trigger a propertyChange script.

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

At the end of the script I set the property to 0, but it looks like the value is not actually being set.

![Screenshot 2025-05-21 081721](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/6/e63088ffd5a3d70860280ce3259c95061a37941f.png)

Debug Log:

 ![Screenshot 2025-05-21 081811](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/0/208a9e943b37009508688d01acfbf8222d3bb369.png)

The property is set to zero eventually, but not being set at the end is causing the script to run twice.

Any ideas on how to fix?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 21, 2025, 3:26pm UTC](https://forum.inductiveautomation.com/t/updating-a-custom-property-in-a-propertychange-script/106510/2 "2025-05-21T15:26:59Z")

</div>

Show your entire script.

But keep in mind that assigning to a Vision component property causes that property's change event to fire **right there** , recursively if called from within that event script.

---

<div class="post-metadata">

**Author:** ![jrusso](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jrusso](https://forum.inductiveautomation.com/u/jrusso)\
**Post date:** [May 21, 2025, 3:29pm UTC](https://forum.inductiveautomation.com/t/updating-a-custom-property-in-a-propertychange-script/106510/3 "2025-05-21T15:29:59Z")

</div>

The script is running twice because you're changing the property from within a property change script. The end of the script causes a property change, and then that property change causes it to run again.

---

<div class="post-metadata">

**Author:** ![pmo](https://avatars.discourse-cdn.com/v4/letter/p/e480ec/32.png) [@pmo](https://forum.inductiveautomation.com/u/pmo)\
**Post date:** [May 21, 2025, 3:42pm UTC](https://forum.inductiveautomation.com/t/updating-a-custom-property-in-a-propertychange-script/106510/4 "2025-05-21T15:42:02Z")

</div>

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

and the complete Debug for this:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/9/59b86580f2bfc5fcaf7fb1ed156d8b2e49efdbbf.png)

I expected that the propertyChange script would run twice, I just expected that the value of the Property would have updated.

Also annoyed that I misspelled "Parrent" in my debugging.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [May 21, 2025, 3:49pm UTC](https://forum.inductiveautomation.com/t/updating-a-custom-property-in-a-propertychange-script/106510/5 "2025-05-21T15:49:15Z")

</div>

Try `print event.newValue, event.source.Trigger`.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 21, 2025, 3:53pm UTC](https://forum.inductiveautomation.com/t/updating-a-custom-property-in-a-propertychange-script/106510/6 "2025-05-21T15:53:09Z")

</div>

The reliable new value in recursion is in `event.newValue`. Consider adding that to your `print` at the top of your script. Consider also using single `print` statements.

For a simpler demonstration, make a temporary component and add a custom integer property `Test`, then add this change event:

```python
if event.propertyName == 'Test':
	print "Pre:", event.newValue, event.source.Test
	if event.newValue < 5:
		nextValue = event.newValue + 1
		event.source.Test = nextValue
		print "Post:", nextValue, event.source.Test

```

Put your designer in preview, and alter that property to some number \< 5. Look at the console output.

---

<div class="post-metadata">

**Author:** ![pmo](https://avatars.discourse-cdn.com/v4/letter/p/e480ec/32.png) [@pmo](https://forum.inductiveautomation.com/u/pmo)\
**Post date:** [May 21, 2025, 3:53pm UTC](https://forum.inductiveautomation.com/t/updating-a-custom-property-in-a-propertychange-script/106510/7 "2025-05-21T15:53:53Z")

</div>

Do I need to create a new Property named newValue? I am getting errors when I try to run.

---

<div class="post-metadata">

**Author:** ![pmo](https://avatars.discourse-cdn.com/v4/letter/p/e480ec/32.png) [@pmo](https://forum.inductiveautomation.com/u/pmo)\
**Post date:** [May 21, 2025, 4:03pm UTC](https://forum.inductiveautomation.com/t/updating-a-custom-property-in-a-propertychange-script/106510/8 "2025-05-21T16:03:49Z")

</div>

Thanks for the help!!!

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

Looks like I need to add some code that verifies that newValue and Property's value match. Or maybe just run the script on the newValue.

Also thanks for the hint on the print statement. I did not realize that I could add comments between values.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 21, 2025, 4:07pm UTC](https://forum.inductiveautomation.com/t/updating-a-custom-property-in-a-propertychange-script/106510/9 "2025-05-21T16:07:51Z")

</div>

> [@pmo](#):
>
> just run the script on the newValue.

This.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [May 21, 2025, 5:00pm UTC](https://forum.inductiveautomation.com/t/updating-a-custom-property-in-a-propertychange-script/106510/10 "2025-05-21T17:00:16Z")

</div>

The key insight is that property change events can sometimes happen before the property is "latched". Ideally, this would be consistently either _before_ or _after_, but between fifteen years of our own component development and the underlying system (Java Swing) I can guarantee that it's not; different properties on different components (or even the same component) will fire before or after the property has actually 'latched' and will reflect the new value when it is next read.

As Phil said - the only safe bet is to rely on `event.newValue`.

> [@pmo](#):
>
> Also thanks for the hint on the print statement.

Somewhat confusingly, what's actually happening is when you say  
`print x, y`  
You're creating a **tuple** `(x, y)` and passing that to `print`. 99% of the time this doesn't matter and it just does what you want, but it's a potentially useful bit of trivia.
