# Pop-up window appears when the tag changes to true

**URL:** <https://forum.inductiveautomation.com/t/pop-up-window-appears-when-the-tag-changes-to-true/53298>\
**Category:** Ignition\
**Tags:** ignition79, database, vision, scripting\
**Created:** [November 19, 2021, 7:12pm UTC](https://forum.inductiveautomation.com/t/pop-up-window-appears-when-the-tag-changes-to-true/53298 "2021-11-19T19:12:14Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![antonio.sanchez](https://avatars.discourse-cdn.com/v4/letter/a/a587f6/32.png) [@antonio.sanchez](https://forum.inductiveautomation.com/u/antonio.sanchez)\
**Post date:** [November 19, 2021, 7:12pm UTC](https://forum.inductiveautomation.com/t/pop-up-window-appears-when-the-tag-changes-to-true/53298/1 "2021-11-19T19:12:14Z")

</div>

Hello everyone

I have a popup window, and I want it to appear when a tag changes from false to true.

I also require it to appear on a defined window, as I have 4 different windows, but I don’t want it to appear on all of them.

---

<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:** [November 19, 2021, 7:43pm UTC](https://forum.inductiveautomation.com/t/pop-up-window-appears-when-the-tag-changes-to-true/53298/2 "2021-11-19T19:43:20Z")

</div>

In the defined window, add a custom property to the root container and bind that tag to it. Define a propertyChange event on the root container that opens the popup when that property becomes true.

---

<div class="post-metadata">

**Author:** ![antonio.sanchez](https://avatars.discourse-cdn.com/v4/letter/a/a587f6/32.png) [@antonio.sanchez](https://forum.inductiveautomation.com/u/antonio.sanchez)\
**Post date:** [December 6, 2021, 3:39pm UTC](https://forum.inductiveautomation.com/t/pop-up-window-appears-when-the-tag-changes-to-true/53298/3 "2021-12-06T15:39:41Z")

</div>

hello @pturmel

thank you very much.

I already added the ‘propertyChange’ event in the window where I want it to appear, but the popup window appears in other windows.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/0/c02f731232afca5258f4ac3dc7746003a64ec068.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:** [December 6, 2021, 4:30pm UTC](https://forum.inductiveautomation.com/t/pop-up-window-appears-when-the-tag-changes-to-true/53298/4 "2021-12-06T16:30:21Z")

</div>

A propertyChange event must always have one or more checks for the correct `event.propertyName`. I don’t see that in your screenshot.

Also, your if statement will never be true, since you are comparing a constant string against a constant integer. Bind the tag to a custom property. (A string containing a tag name doesn’t magically become the tag value.)

---

<div class="post-metadata">

**Author:** ![antonio.sanchez](https://avatars.discourse-cdn.com/v4/letter/a/a587f6/32.png) [@antonio.sanchez](https://forum.inductiveautomation.com/u/antonio.sanchez)\
**Post date:** [December 7, 2021, 9:09pm UTC](https://forum.inductiveautomation.com/t/pop-up-window-appears-when-the-tag-changes-to-true/53298/5 "2021-12-07T21:09:49Z")

</div>

> [@pturmel](#):
>
> A propertyChange event must always have one or more checks for the correct `event.propertyName` . I don’t see that in your screenshot.
> 
> Also, your if statement will never be true, since you are comparing a constant string against a constant integer. Bind the tag to a custom property. (A string containing a tag name doesn’t magically become the tag value.)

I have something like this

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/5/d5d44659f1f1fb8ec2b6f16551902b3f0986d0c6.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:** [December 7, 2021, 9:17pm UTC](https://forum.inductiveautomation.com/t/pop-up-window-appears-when-the-tag-changes-to-true/53298/6 "2021-12-07T21:17:36Z")

</div>

You code runs when _ **any** _ property of that component changes. That is certainly wrong. Use an `if` statement to compare `event.propertyName` against the property that should be triggering your code. Everything else (everything you have now) should be indented under that `if` statement.

---

<div class="post-metadata">

**Author:** ![antonio.sanchez](https://avatars.discourse-cdn.com/v4/letter/a/a587f6/32.png) [@antonio.sanchez](https://forum.inductiveautomation.com/u/antonio.sanchez)\
**Post date:** [December 8, 2021, 10:43pm UTC](https://forum.inductiveautomation.com/t/pop-up-window-appears-when-the-tag-changes-to-true/53298/7 "2021-12-08T22:43:17Z")

</div>

> [@pturmel](#):
>
> event.propertyName

do you have an example?

---

<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:** [December 8, 2021, 11:02pm UTC](https://forum.inductiveautomation.com/t/pop-up-window-appears-when-the-tag-changes-to-true/53298/8 "2021-12-08T23:02:26Z")

</div>

Examples all over this forum:

[https://forum.inductiveautomation.com/search?q=event.propertyName](https://forum.inductiveautomation.com/search?q=event.propertyName)

---

<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:** [December 8, 2021, 11:05pm UTC](https://forum.inductiveautomation.com/t/pop-up-window-appears-when-the-tag-changes-to-true/53298/9 "2021-12-08T23:05:53Z")

</div>

Use the custom property name to which you bound your tag. No need to read the tag in your script since its value is in the custom property.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [December 8, 2021, 11:38pm UTC](https://forum.inductiveautomation.com/t/pop-up-window-appears-when-the-tag-changes-to-true/53298/10 "2021-12-08T23:38:50Z")

</div>

as a fun exercise, add this into your propertyChange event handler code:

```auto
print 'PropertyChange name: ', event.propertyName

```

Then save, close the resource, open your console in your designer or your client, and open the page again and see the number of propertyChange events you see. This will show you why you need to single-out the property name you’re looking for with:

```auto
if event.propertyName == 'property name':

```

---

<div class="post-metadata">

**Author:** ![Alaa\_Soulaiman](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alaa_soulaiman/32/69782_2.png) [@Alaa\_Soulaiman](https://forum.inductiveautomation.com/u/Alaa_Soulaiman)\
**Post date:** [November 13, 2024, 8:25pm UTC](https://forum.inductiveautomation.com/t/pop-up-window-appears-when-the-tag-changes-to-true/53298/11 "2024-11-13T20:25:27Z")

</div>

When doing this, I also followed your other comments about something with only caring about one property changing, but before and after I added the propertyName into my code, I still continued getting the message box that I have to pop open, about 3-5 times popping up before it stops everytime I open the window that has the propertyChange script in it.

Below is my code. I assume you have experience with what I am talking about.

Basically I am trying to get the IP address of a screen that I am using to compare which screen it is, first screen to access that page or second. If it is the second screen, click a button to gain access and write over those tags that stored the previous ip addresses. Once the ip address is the same, pop open a message box that access has been granted...

My main issue is ONLY that it pops open as I said 3-5 message boxes once I open that screen until it stops, then doesn't do it again until that screen is opened again.

```python
# Check if the changed property is the custom property we want
firstUserIP = system.tag.readBlocking(["[Path]tempTags/sCurrentUser_IP"])[0].value # Adjusted to retrievethe actual tag value
secondUserIP = system.net.getIpAddress() # Adjusted to retrievethe actual ip

if event.propertyName == "ScreenNumber":
    newValue = event.newValue
    
    # Check if the current IP is different from the first user IP
    if firstUserIP != secondUserIP:
        system.gui.messageBox("Someone else is on the page")
        #system.nav.closeWindow("Main Windows/TheScreenTest")
        
    else:
        system.gui.messageBox("Access granted")
    
    # Display the new value of the property
    system.gui.messageBox("The new value of ScreenNumber is: " + str(newValue))

```

---

<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:** [November 13, 2024, 8:30pm UTC](https://forum.inductiveautomation.com/t/pop-up-window-appears-when-the-tag-changes-to-true/53298/12 "2024-11-13T20:30:48Z")

</div>

`if event.propertyName == "ScreenNumber":`  
I would print or log the value of this proprety somewhere, your `newValue` variable. Perhaps this ScreenNumber is changing more than you think, triggering this more than you expected.

---

<div class="post-metadata">

**Author:** ![Alaa\_Soulaiman](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alaa_soulaiman/32/69782_2.png) [@Alaa\_Soulaiman](https://forum.inductiveautomation.com/u/Alaa_Soulaiman)\
**Post date:** [November 13, 2024, 8:37pm UTC](https://forum.inductiveautomation.com/t/pop-up-window-appears-when-the-tag-changes-to-true/53298/13 "2024-11-13T20:37:12Z")

</div>

> [@bkarabinchak.psi](#):
>
> I would print or log the value of this proprety somewhere, your `newValue` variable. Perhaps this ScreenNumber is changing more than you think, triggering this more than you expe

Well I do have it binded to a tag, that when i press the button, it assigns a value desired. Yet continues to pop open a few messages when i open that window again. When I click ok on all of them, the screen does actually do what I want. I assume some sort of property changes on all properties when the window is closed AND opened...Wonder if there is a way around this.

---

<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:** [November 13, 2024, 8:57pm UTC](https://forum.inductiveautomation.com/t/pop-up-window-appears-when-the-tag-changes-to-true/53298/14 "2024-11-13T20:57:30Z")

</div>

You are performing work in a propertyChange event (readBlocking, getIpAddress) before checking the event's propertyName. Don't do that. Don't do **any** work in a propertyChange event outside the `if` block.

---

<div class="post-metadata">

**Author:** ![Alaa\_Soulaiman](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alaa_soulaiman/32/69782_2.png) [@Alaa\_Soulaiman](https://forum.inductiveautomation.com/u/Alaa_Soulaiman)\
**Post date:** [November 13, 2024, 9:01pm UTC](https://forum.inductiveautomation.com/t/pop-up-window-appears-when-the-tag-changes-to-true/53298/15 "2024-11-13T21:01:35Z")

</div>

How else do I define it inside the "if" if I have to define it prior to my code inside the second "if", yet highlights the second line "secondUserIP" as if it is not indented or formatted correctly.  
EDIT: Even after removing the "secondUserIP" line, it still continued to do this after putting in all work inside the "if propertyName" anyways

---

<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:** [November 13, 2024, 9:06pm UTC](https://forum.inductiveautomation.com/t/pop-up-window-appears-when-the-tag-changes-to-true/53298/16 "2024-11-13T21:06:12Z")

</div>

Your yellow highlight is just below a red squiggle that indicates a jython syntax error on that line.

You aren't showing the whole code on that line, so not resolvable by us.

Also, you should not be using `system.tag.readBlocking()` in a Vision event script at all--it makes a potentially slow callout across the network that can freeze your client. Bind that tag to another custom property (tag binding) and check that property in your event script.

Let me add:

The code shown suggests that you are attempting to deny access to something **after** it has already happened. (Screen number that someone else is using.) This is a problem, as the only practical way to deny access is to do it **before** it happens. Your code shown just pops up messages, but doesn't actually deny any access.

Both Vision and Perspective have security controls that can be attached to Windows/Views to actually **prevent** usage. Pretty much all other navigation control cannot be stopped. Which means the operation that you can **actually** impact is **use of input fields**. By disabling them with bindings (not scripts) appropriate to the situation.

Consider an alternate approach. (And share more, so we can help more effectively.)

Final Note: In Vision, consider **not** using IP address to identify various workstations. Use the client's unique ID in your algorithm above. And, where specificity is required, use Ethernet MAC ID instead of IP address. Much more reliable identity.

---

<div class="post-metadata">

**Author:** ![Alaa\_Soulaiman](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alaa_soulaiman/32/69782_2.png) [@Alaa\_Soulaiman](https://forum.inductiveautomation.com/u/Alaa_Soulaiman)\
**Post date:** [November 13, 2024, 9:40pm UTC](https://forum.inductiveautomation.com/t/pop-up-window-appears-when-the-tag-changes-to-true/53298/17 "2024-11-13T21:40:23Z")

</div>

I agree that it is more practical to use the client id as opposed to IP address, however, the project I am working on is requesting that when the second client enters the same screen that the first client is on, to kick off the first person instead of blocking it out prior to entry...I came back to this as I had a few other tasks to do but this was a discussion I posted about a month ago and yes, I understand that a message box doesn't actually close anything, but when both screens overcome the overload of message boxes, it works exactly how I want, the message boxes appear on the correct screens as desired and "access granted" message appears where I want it. By logic, if I get the message boxes to stop spamming the screen when initially entering the screen, it then can be utilized to kick the first user out as intended similar to how the first screen will get the "someone else using screen" and second screen gets the access granted message. As this will mean that I managed to get it to stop running the propertyChange event 3-5 times prior to even entering the screen and getting a chance to run it correctly as intended

Currently I have a button that on release, performs this and as mentioned, functions correctly as well as allows my propertyChange script to run once and how I want it once actually overcoming the spam of message boxes:

```python
# Retrieve the IP address of the client
active_ip = system.net.getIpAddress()

# Define the tag path where the IP address will be stored
tag_path = "[Path]tempTags/sCurrentUser_IP"  

# Write the IP address to the specified tag
system.tag.writeBlocking([tag_path], [active_ip])

if active_ip == '10.77.07.10':
	system.tag.writeBlocking("[Path]tempTags/iScreenNumber.value", 1)
elif active_ip == '10.16.05.11':
	system.tag.writeBlocking("[Path]tempTags/iScreenNumber.value", 2)
elif active_ip == '10.16.05.12':
	system.tag.writeBlocking("[Path]tempTags/iScreenNumber.value", 3)
elif active_ip == '10.16.05.13':
	system.tag.writeBlocking("[Path]tempTags/iScreenNumber.value", 4)

```

---

<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:** [November 13, 2024, 9:46pm UTC](https://forum.inductiveautomation.com/t/pop-up-window-appears-when-the-tag-changes-to-true/53298/18 "2024-11-13T21:46:55Z")

</div>

> [@Alaa\_Soulaiman](#):
>
> more ~~practical~~ _ **reliable** _ to use the client id as opposed to IP address

Fixed that for you.

Consider not using any popups. Just a visionWindowActivated script that writes the current client ID to the appropriate tag in the gateway.

In the Window's root container, bind that tag to a custom property. In another custom property, a boolean, called `permission` perhaps, use an expression to compare that tag value (via the bound property) to the current client ID (in the system provider). Tie the enable property of all input fields to that root container `permission` property.

Any time that window is opened, anywhere else it is open will simply go grey.

---

<div class="post-metadata">

**Author:** ![Alaa\_Soulaiman](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alaa_soulaiman/32/69782_2.png) [@Alaa\_Soulaiman](https://forum.inductiveautomation.com/u/Alaa_Soulaiman)\
**Post date:** [November 13, 2024, 9:57pm UTC](https://forum.inductiveautomation.com/t/pop-up-window-appears-when-the-tag-changes-to-true/53298/19 "2024-11-13T21:57:45Z")

</div>

Thank you so much for your help. Ill take a look at this tomorrow.
