# PropertyChange Event script

**URL:** <https://forum.inductiveautomation.com/t/propertychange-event-script/3686>\
**Category:** Ignition\
**Created:** [December 2, 2011, 12:13am UTC](https://forum.inductiveautomation.com/t/propertychange-event-script/3686 "2011-12-02T00:13:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![scott\_rister](https://avatars.discourse-cdn.com/v4/letter/s/5daacb/32.png) [@scott\_rister](https://forum.inductiveautomation.com/u/scott_rister)\
**Post date:** [December 2, 2011, 12:13am UTC](https://forum.inductiveautomation.com/t/propertychange-event-script/3686/1 "2011-12-02T00:13:42Z")

</div>

i have an Event script that is not quite working out for me and hoping to get some help.  
it is a propertyChange script like this:  
if event.propertyName == “HS\_RETURN”:  
if event.source.HS\_RETURN == 1:  
value = 0  
event.source.HS\_OUT = value  
event.source.HS\_RETURN = value

i have towo dynamc properties defined, HS\_OUT and HS\_RETURN, both are bound to plc Tags. When HS\_RETURN changes from a 0 to a 1, i want to clear both bits. The script triggers and executes properly both properties being cleared, however, only the tag bound to HS\_OUT gets cleared, the tag bound to HS\_RETURN stays set even though the actual property is 0. Both tags are configured with ReadWrite access rights and both properties are set to allow bi-directional.  
Any Thoughts?  
Thanks,  
Scott

---

<div class="post-metadata">

**Author:** ![ISDProj](https://avatars.discourse-cdn.com/v4/letter/i/58956e/32.png) [@ISDProj](https://forum.inductiveautomation.com/u/ISDProj)\
**Post date:** [December 2, 2011, 12:38am UTC](https://forum.inductiveautomation.com/t/propertychange-event-script/3686/2 "2011-12-02T00:38:52Z")

</div>

You would need to be looking at the Event.NewValue if you are using the “property.change” event (casing may be incorrect for event.newvalue as I’m working from memory 😊 )  
I also think it may need to be set as an “invoke later” type script if you are wanting to change the value that is changing…

Hope this helps a bit.

---

<div class="post-metadata">

**Author:** ![scott\_rister](https://avatars.discourse-cdn.com/v4/letter/s/5daacb/32.png) [@scott\_rister](https://forum.inductiveautomation.com/u/scott_rister)\
**Post date:** [December 2, 2011, 1:11am UTC](https://forum.inductiveautomation.com/t/propertychange-event-script/3686/3 "2011-12-02T01:11:23Z")

</div>

Thanks,  
i think you may be on to something with the invokeLater thing.  
I have never defined a function before though and seem to be having difficulty with the syntax.  
Can you help me out?  
How do i turn my little script shown in my original post into a function that can be called with the invokeLater call?  
Thanks again.

---

<div class="post-metadata">

**Author:** ![Brett\_Yeomans](https://avatars.discourse-cdn.com/v4/letter/b/35a633/32.png) [@Brett\_Yeomans](https://forum.inductiveautomation.com/u/Brett_Yeomans)\
**Post date:** [December 2, 2011, 6:00pm UTC](https://forum.inductiveautomation.com/t/propertychange-event-script/3686/4 "2011-12-02T18:00:50Z")

</div>

Never having tried this before I finally got the following to work with 2 DB tags. The following is from a Gateway Tag Change script whose Tag Path is tagchangetest1 :

value = newValue.value  
if value == 1:   
def reset():  
import system  
value = 0  
system.tag.writeToTag(“tagchangetest2”, value )  
system.tag.writeToTag(“tagchangetest1”, value )  
reset()

If I set tagchangetest2 to ON and then do the same to tagchangetest1 both tags go OFF. Tried the invokelater and could not get to work.  
Have no idea if this helps but thought I’d give it a go 😆  
edit: It appears the tabs disappear on the forum so you need to add these.

---

<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:** [December 2, 2011, 7:28pm UTC](https://forum.inductiveautomation.com/t/propertychange-event-script/3686/5 "2011-12-02T19:28:01Z")

</div>

[quote=“Brett Yeomans”]  
edit: It appears the tabs disappear on the forum so you need to add these.[/quote]  
If you wrap it in a [code][/code] it should put it in. ![:thumb_right:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/2026e28c0c425034352c1b75807edf956adc75f4.gif ":thumb\_right:")

`value = newValue.value
if value == 1:	
	def reset():
		import system
		value = 0
		system.tag.writeToTag("tagchangetest2", value )
		system.tag.writeToTag("tagchangetest1", value )
	reset()`
