# propertyChange does not work for me

**URL:** <https://forum.inductiveautomation.com/t/propertychange-does-not-work-for-me/85556>\
**Category:** Ignition\
**Tags:** ignition81, vision\
**Created:** [February 12, 2024, 3:07pm UTC](https://forum.inductiveautomation.com/t/propertychange-does-not-work-for-me/85556 "2024-02-12T15:07:28Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Miguel\_Cimildoro](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@Miguel\_Cimildoro](https://forum.inductiveautomation.com/u/Miguel_Cimildoro)\
**Post date:** [February 12, 2024, 3:07pm UTC](https://forum.inductiveautomation.com/t/propertychange-does-not-work-for-me/85556/1 "2024-02-12T15:07:28Z")

</div>

I have a customProperty called counter that increments every second

I want that when it reaches 10sec, it closes the page... what am I doing wrong?

```auto
if event.propertyName == 'counter':  
        if event.newValue == 10:  
            system.nav.closeWindow('2-DEVELOP/2-SYSTEM/3-BMS LEVELS/Popup Maitenance Mode/ProgressBar_Counter')

```

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

---

<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:** [February 12, 2024, 3:12pm UTC](https://forum.inductiveautomation.com/t/propertychange-does-not-work-for-me/85556/2 "2024-02-12T15:12:50Z")

</div>

Please **edit** your post to use "Preformatted text" formatting for the code you pasted. It's the button in the comment editor that looks like this: \</\>  
We can't see your indentation, and it matters.

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [February 12, 2024, 3:46pm UTC](https://forum.inductiveautomation.com/t/propertychange-does-not-work-for-me/85556/3 "2024-02-12T15:46:10Z")

</div>

On what @pturmel 's point it seems like you have 8 spaces indented on your line on your first indented `if` statement but it should be 4 spaces or 1 tab. Try fixing your indentation first and then see if you're still experiencing an issue (and open up console and see if it's spitting out an errors).

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [February 12, 2024, 3:50pm UTC](https://forum.inductiveautomation.com/t/propertychange-does-not-work-for-me/85556/4 "2024-02-12T15:50:17Z")

</div>

The first step when something doesn't work is to open the console and see if there are errors there.  
Maybe nothing happens because something is broken. The console will tell you that.

---

<div class="post-metadata">

**Author:** ![Miguel\_Cimildoro](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@Miguel\_Cimildoro](https://forum.inductiveautomation.com/u/Miguel_Cimildoro)\
**Post date:** [February 12, 2024, 4:05pm UTC](https://forum.inductiveautomation.com/t/propertychange-does-not-work-for-me/85556/5 "2024-02-12T16:05:02Z")

</div>

> [@bkarabinchak.psi](#):
>
> On what @pturmel 's point it seems like you have 8 spaces indented on your line on your first indented `if` statement but it should be 4 spaces or 1 tab. Try fixing your indentation first and then see if you're still experiencing an issue (and open up console and see if it's spitting out an errors).

yes I have corrected it and it is still the same, in fact I put a print "house" in the following line and it does not print it by console

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [February 12, 2024, 4:24pm UTC](https://forum.inductiveautomation.com/t/propertychange-does-not-work-for-me/85556/6 "2024-02-12T16:24:00Z")

</div>

I just tried this and it works as expected:

```python
if event.propertyName == 'counter' and event.newValue == 10:
	print "Hey there"

```

---

<div class="post-metadata">

**Author:** ![Miguel\_Cimildoro](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@Miguel\_Cimildoro](https://forum.inductiveautomation.com/u/Miguel_Cimildoro)\
**Post date:** [February 12, 2024, 4:30pm UTC](https://forum.inductiveautomation.com/t/propertychange-does-not-work-for-me/85556/7 "2024-02-12T16:30:19Z")

</div>

Did you create the customPropertie inside the root.container of the window where we are making the script?

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

---

<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:** [February 12, 2024, 4:32pm UTC](https://forum.inductiveautomation.com/t/propertychange-does-not-work-for-me/85556/8 "2024-02-12T16:32:41Z")

</div>

The event must be on the root container, not the window, if you are monitoring a root container property. Putting the event on the window will only catch changes to the **window's** own properties.

---

<div class="post-metadata">

**Author:** ![Miguel\_Cimildoro](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@Miguel\_Cimildoro](https://forum.inductiveautomation.com/u/Miguel_Cimildoro)\
**Post date:** [February 12, 2024, 4:41pm UTC](https://forum.inductiveautomation.com/t/propertychange-does-not-work-for-me/85556/9 "2024-02-12T16:41:04Z")

</div>

I don't understand, if I want a window to close when a counter (customProperty) is equal to 5 (that's what I want to do). I have the custom created inside the root container of the PopupWindow and it is that custom that I am trying to interact with the closing of the window.

---

<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:** [February 12, 2024, 4:46pm UTC](https://forum.inductiveautomation.com/t/propertychange-does-not-work-for-me/85556/10 "2024-02-12T16:46:13Z")

</div>

A property change event is only sent to the component that has the property. The root container of a window **is not the window**. Move your event script to the root container.

---

<div class="post-metadata">

**Author:** ![Miguel\_Cimildoro](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@Miguel\_Cimildoro](https://forum.inductiveautomation.com/u/Miguel_Cimildoro)\
**Post date:** [February 12, 2024, 4:50pm UTC](https://forum.inductiveautomation.com/t/propertychange-does-not-work-for-me/85556/11 "2024-02-12T16:50:30Z")

</div>

omg!!! now I see it... indeed that was... thank you very much for the class Phill! I learned a lot with that explanation.
