# propertyChange Event Executes on Form Load

**URL:** <https://forum.inductiveautomation.com/t/propertychange-event-executes-on-form-load/22942>\
**Category:** Ignition\
**Tags:** ignition79\
**Created:** [February 27, 2019, 6:14pm UTC](https://forum.inductiveautomation.com/t/propertychange-event-executes-on-form-load/22942 "2019-02-27T18:14:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mwolter](https://avatars.discourse-cdn.com/v4/letter/m/258eb7/32.png) [@mwolter](https://forum.inductiveautomation.com/u/mwolter)\
**Post date:** [February 27, 2019, 6:14pm UTC](https://forum.inductiveautomation.com/t/propertychange-event-executes-on-form-load/22942/1 "2019-02-27T18:14:49Z")

</div>

I have the following code on the propertyChange event of a dropdown box and it executes on form load.  
I only want it to execute when the selected value changes.  
I’m new to Ignition, so any help would be appreciated, Thanks.

```auto
if event.propertyName == 'selectedStringValue':
	tank = '57'
	productNew = event.newValue
	productOld = event.oldValue	
	userName = system.security.getUsername()
	user = system.user.getUser("", userName)
	userid = user.get(user.FirstName) + " " + user.get(user.LastName)
	today = system.date.now()
	todayf = system.date.format(today, "yyyy-MM-dd HH:mm:ss")
	comp = system.net.getHostName()
	system.db.runUpdateQuery("INSERT INTO TankHistory(TankNumber, TankProductOld, TankProductNew, t_Userid, t_stamp, ClientCPU) " + "VALUES ('%s', '%s', '%s', '%s', '%s', '%s')" %(tank, productOld, productNew, userid, todayf, comp))

```

---

<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:** [February 27, 2019, 6:16pm UTC](https://forum.inductiveautomation.com/t/propertychange-event-executes-on-form-load/22942/2 "2019-02-27T18:16:45Z")

</div>

> [@mwolter](#):
>
> `if event.propertyName == 'selectedStringValue':`

Try changing that to:  
`if event.propertyName == 'selectedStringValue' and event.source.componentRunning:`

---

<div class="post-metadata">

**Author:** ![mwolter](https://avatars.discourse-cdn.com/v4/letter/m/258eb7/32.png) [@mwolter](https://forum.inductiveautomation.com/u/mwolter)\
**Post date:** [February 27, 2019, 6:44pm UTC](https://forum.inductiveautomation.com/t/propertychange-event-executes-on-form-load/22942/3 "2019-02-27T18:44:54Z")

</div>

Thank You, it looks like that worked…

---

<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:** [February 27, 2019, 7:20pm UTC](https://forum.inductiveautomation.com/t/propertychange-event-executes-on-form-load/22942/4 "2019-02-27T19:20:36Z")

</div>

For an explanation: The ‘selectedStringValue’ is (probably) changing on your component more than once because there’s an initial set of the value as the component is created, then another as the last saved value in the designer is applied, and then a third when any binding(s) that affect the component are evaluated. The `componentRunning` flag is only set when all of those things have been completed.
