# Scripting on propertyChange issue

**URL:** <https://forum.inductiveautomation.com/t/scripting-on-propertychange-issue/21994>\
**Category:** Ignition\
**Tags:** ignition79, scripting\
**Created:** [January 19, 2019, 9:11am UTC](https://forum.inductiveautomation.com/t/scripting-on-propertychange-issue/21994 "2019-01-19T09:11:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![enrico.merlo](https://avatars.discourse-cdn.com/v4/letter/e/b77776/32.png) [@enrico.merlo](https://forum.inductiveautomation.com/u/enrico.merlo)\
**Post date:** [January 19, 2019, 9:11am UTC](https://forum.inductiveautomation.com/t/scripting-on-propertychange-issue/21994/1 "2019-01-19T09:11:13Z")

</div>

Hi,  
I have a problem with calendar component scripting; I want to run a script on selected date changing. Here it’s what I do:

if event.propertyName==“date”:  
#do some stuff

the issue is that for every date change, I have the script run 2 times, and I can’t understand why.  
Any guess?

Thanks,  
Enrico

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [January 19, 2019, 3:25pm UTC](https://forum.inductiveautomation.com/t/scripting-on-propertychange-issue/21994/2 "2019-01-19T15:25:51Z")

</div>

I would say this is a bug with the regular calendar control.  
@paul-griffith  
If you use the popup calendar instead the events only fire once.

---

<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:** [January 22, 2019, 4:12pm UTC](https://forum.inductiveautomation.com/t/scripting-on-propertychange-issue/21994/3 "2019-01-22T16:12:39Z")

</div>

Not a bug so much as a necessary evil - without looking into it, I believe the “duplicate” events are related to locale formatting or something along those lines. The various `latched*Date` properties should behave the way you want them to.

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [January 22, 2019, 7:01pm UTC](https://forum.inductiveautomation.com/t/scripting-on-propertychange-issue/21994/4 "2019-01-22T19:01:37Z")

</div>

I would agree if you could trap for that but the control doesn't allow it.  
On the regular calendar control, propertyChange event.  
print event.propertyName returns this on date click:

> formattedDate  
> date  
> formattedDate  
> date

While on the popup calendar control it returns

> date  
> text  
> formattedDate

So with the normal calendar control you can't trap for formattedDate and run code a single time.

---

<div class="post-metadata">

**Author:** ![jpark](https://avatars.discourse-cdn.com/v4/letter/j/a88e57/32.png) [@jpark](https://forum.inductiveautomation.com/u/jpark)\
**Post date:** [January 22, 2019, 8:04pm UTC](https://forum.inductiveautomation.com/t/scripting-on-propertychange-issue/21994/5 "2019-01-22T20:04:45Z")

</div>

You can create a custom date property on the component and bind it to the date. Then do the property change event on the new property.

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [January 22, 2019, 9:23pm UTC](https://forum.inductiveautomation.com/t/scripting-on-propertychange-issue/21994/6 "2019-01-22T21:23:37Z")

</div>

I understand that, but that still doesn’t explain why it is firing date and formattedDate twice like that.
