# How to open a popup based on tag value?

**URL:** <https://forum.inductiveautomation.com/t/how-to-open-a-popup-based-on-tag-value/7574>\
**Category:** Ignition\
**Created:** [November 15, 2013, 3:09pm UTC](https://forum.inductiveautomation.com/t/how-to-open-a-popup-based-on-tag-value/7574 "2013-11-15T15:09:23Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![rcorkern](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@rcorkern](https://forum.inductiveautomation.com/u/rcorkern)\
**Post date:** [November 15, 2013, 3:09pm UTC](https://forum.inductiveautomation.com/t/how-to-open-a-popup-based-on-tag-value/7574/1 "2013-11-15T15:09:23Z")

</div>

I’d like to open a popup based on the value of a tag. I have tried this as a timer client and tag change client script, both with no luck. On the tag change script, if I change that tags value then I get the popup, but it’s like it’s not seeing the condition. any ideas what I am doing wrong or where I need to put this code

if “testPressureOut” \> 15000:  
system.nav.openWindow(‘SHP\_popup’)  
system.nav.centerWindow(‘SHP\_popup’)  
else:  
system.nav.closeWindow(‘SHP\_popup’)

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [November 15, 2013, 4:03pm UTC](https://forum.inductiveautomation.com/t/how-to-open-a-popup-based-on-tag-value/7574/2 "2013-11-15T16:03:41Z")

</div>

Hi,

Your condition compares a string to a number which doesn’t make sense.

Maybe you mean this:

```auto
if testPressureOut > 15000:
    system.nav.openWindow('SHP_popup')
    system.nav.centerWindow('SHP_popup')
else:
    system.nav.closeWindow('SHP_popup')
```

---

<div class="post-metadata">

**Author:** ![rcorkern](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@rcorkern](https://forum.inductiveautomation.com/u/rcorkern)\
**Post date:** [November 15, 2013, 4:15pm UTC](https://forum.inductiveautomation.com/t/how-to-open-a-popup-based-on-tag-value/7574/3 "2013-11-15T16:15:25Z")

</div>

Where would I put it? I’ve tried both client timer and tag change scripts

---

<div class="post-metadata">

**Author:** ![adamaustin](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@adamaustin](https://forum.inductiveautomation.com/u/adamaustin)\
**Post date:** [November 15, 2013, 4:21pm UTC](https://forum.inductiveautomation.com/t/how-to-open-a-popup-based-on-tag-value/7574/4 "2013-11-15T16:21:23Z")

</div>

Yea, you can add that code in the Timer event (make sure it is RUNNING). This kind of gives you the whole picture:

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/f/4fc3d9c8fec4be7c47e963f3eab1ebc2539fd5ba.jpeg)

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [November 15, 2013, 4:22pm UTC](https://forum.inductiveautomation.com/t/how-to-open-a-popup-based-on-tag-value/7574/5 "2013-11-15T16:22:07Z")

</div>

Either one would work.

How are you getting the value of the tag?

Are you getting it like this:

```auto
testPressureOut = system.tag.read("[default]foler/folder/mytag").value
```

---

<div class="post-metadata">

**Author:** ![rcorkern](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@rcorkern](https://forum.inductiveautomation.com/u/rcorkern)\
**Post date:** [November 15, 2013, 4:40pm UTC](https://forum.inductiveautomation.com/t/how-to-open-a-popup-based-on-tag-value/7574/6 "2013-11-15T16:40:04Z")

</div>

It works in the timer script on the page but ultimately i’d like the popup to be there as long as the value is \> X, and go away when the value drops below X. Won’t this need to be in a client script so that no matter what page is currently open that it will always be checking this value?

---

<div class="post-metadata">

**Author:** ![diat150](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@diat150](https://forum.inductiveautomation.com/u/diat150)\
**Post date:** [November 15, 2013, 4:48pm UTC](https://forum.inductiveautomation.com/t/how-to-open-a-popup-based-on-tag-value/7574/7 "2013-11-15T16:48:36Z")

</div>

you should be able to stick this in a tag change script. put the tag in the tag list for the tag change script. Then you need to modify the script that adam or mudge posted to fit your tag path and window name. I would also put some print statements to see what is going on.

`
print "start script"
testPressureOut = system.tag.read("[default]foler/folder/mytag").value
print testPressureOut
if testPressureOut > 15000:
    print "pressure greater than 15000, open window"
    system.nav.openWindow('SHP_popup')
    system.nav.centerWindow('SHP_popup')
else:
    print "pressure less than 15000, do nothing"
    system.nav.closeWindow('SHP_popup')`

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [November 15, 2013, 4:49pm UTC](https://forum.inductiveautomation.com/t/how-to-open-a-popup-based-on-tag-value/7574/8 "2013-11-15T16:49:37Z")

</div>

Yes. Put it in a client script. The documentation says how to get the new value that changed: [inductiveautomation.com/support/ … cripts.htm](http://inductiveautomation.com/support/usermanuals/ignition/index.html?tag_change_scripts.htm)

From the Ignition User Manual:

```auto
print "Received tag change event for %s" % event.tagPath
value = newValue.value
quality = newValue.quality
timestamp = newValue.timestamp
print "value=%s, quality=%s, timestamp=%s" %(value, quality, timestamp)
```

---

<div class="post-metadata">

**Author:** ![rcorkern](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@rcorkern](https://forum.inductiveautomation.com/u/rcorkern)\
**Post date:** [November 15, 2013, 5:13pm UTC](https://forum.inductiveautomation.com/t/how-to-open-a-popup-based-on-tag-value/7574/9 "2013-11-15T17:13:10Z")

</div>

i’m still not having luck with it, I’ve even tried different tags just to make sure and I’ve even deleted and recreated that test mem tag (testPressureOut). hmmm

---

<div class="post-metadata">

**Author:** ![adamaustin](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@adamaustin](https://forum.inductiveautomation.com/u/adamaustin)\
**Post date:** [November 15, 2013, 5:34pm UTC](https://forum.inductiveautomation.com/t/how-to-open-a-popup-based-on-tag-value/7574/10 "2013-11-15T17:34:31Z")

</div>

Try using event.newValue in the Tag Change event:

```auto
testPressureOut = event.newValue

try:
	if testPressureOut > 15000:
		system.nav.openWindow("SHP_popup")
		system.nav.centerWindow("SHP_popup")
	else:
		system.nav.closeWindow("SHP_popup")
except:
	#window is already opened/closed
	pass

```

---

<div class="post-metadata">

**Author:** ![diat150](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@diat150](https://forum.inductiveautomation.com/u/diat150)\
**Post date:** [November 15, 2013, 6:46pm UTC](https://forum.inductiveautomation.com/t/how-to-open-a-popup-based-on-tag-value/7574/11 "2013-11-15T18:46:51Z")

</div>

> [@rcorkern](#):
>
> i'm still not having luck with it, I've even tried different tags just to make sure and I've even deleted and recreated that test mem tag (testPressureOut). hmmm

you do have the testPressureOut tag in the tag change script tag list under the tag tab in your screenshot right? also, that print statement needs to be "print testPressureOut", not "print testValue". thats probably why it is failing, because it doesnt recognize that variable.

---

<div class="post-metadata">

**Author:** ![rcorkern](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@rcorkern](https://forum.inductiveautomation.com/u/rcorkern)\
**Post date:** [November 15, 2013, 7:05pm UTC](https://forum.inductiveautomation.com/t/how-to-open-a-popup-based-on-tag-value/7574/12 "2013-11-15T19:05:29Z")

</div>

Hey diat150 yes, I noticed that typo and corrected. Now the script runs and everytime I change that testPressureOut value I get the popup, regardless of whether or not it’s above or below 15000. weird…

---

<div class="post-metadata">

**Author:** ![rcorkern](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@rcorkern](https://forum.inductiveautomation.com/u/rcorkern)\
**Post date:** [November 15, 2013, 7:28pm UTC](https://forum.inductiveautomation.com/t/how-to-open-a-popup-based-on-tag-value/7574/13 "2013-11-15T19:28:58Z")

</div>

this code worked good:

print “start script”  
testPressureOut = system.tag.read(“testPressureOut”).value  
print testPressureOut  
if testPressureOut \> 15000:  
print “pressure greater than 15000, open window”  
system.nav.openWindow(‘SHP\_popup’)  
system.nav.centerWindow(‘SHP\_popup’)  
else:  
print “pressure less than 15000, do nothing”  
system.nav.closeWindow(‘SHP\_popup’)

thanks!

---

<div class="post-metadata">

**Author:** ![tpenke63](https://avatars.discourse-cdn.com/v4/letter/t/5fc32e/32.png) [@tpenke63](https://forum.inductiveautomation.com/u/tpenke63)\
**Post date:** [January 6, 2014, 9:21pm UTC](https://forum.inductiveautomation.com/t/how-to-open-a-popup-based-on-tag-value/7574/14 "2014-01-06T21:21:17Z")

</div>

Anyone have any idea on how to do this on a mouse click script? I have a graphic that I want to run a mouse clicked script on… where if the tag is =1 I want one pop-up to open, and if it’s =0 I want a different pop-up to open.

I’ve tried this:

selectONE = system.tag.read("[]/MyTag").value

```
 if selectONE=1:
 system.nav.openWindow('ThisPopup')
 system.nav.centerWindow('ThisPopup')
 else:
 system.nav.openWindow('ThatPopup')
 system.nav.centerWindow('ThatPopup')

```

it borks out on an EOF on if selectONE=1

Thanks!

---

<div class="post-metadata">

**Author:** ![adamaustin](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@adamaustin](https://forum.inductiveautomation.com/u/adamaustin)\
**Post date:** [January 6, 2014, 9:29pm UTC](https://forum.inductiveautomation.com/t/how-to-open-a-popup-based-on-tag-value/7574/15 "2014-01-06T21:29:49Z")

</div>

Try using the [equal comparison](http://docs.python.org/release/2.5.2/lib/comparisons.html) (==) in python:

```auto
selectONE = system.tag.read("[]/MyTag").value

if selectONE==1:
	system.nav.openWindow('ThisPopup')
	system.nav.centerWindow('ThisPopup')
else:
	system.nav.openWindow('ThatPopup')
	system.nav.centerWindow('ThatPopup')
```

---

<div class="post-metadata">

**Author:** ![adamaustin](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@adamaustin](https://forum.inductiveautomation.com/u/adamaustin)\
**Post date:** [January 6, 2014, 9:31pm UTC](https://forum.inductiveautomation.com/t/how-to-open-a-popup-based-on-tag-value/7574/16 "2014-01-06T21:31:59Z")

</div>

Also, make sure you have your Tag path correct. Try this, too:

```auto
selectONE = system.tag.read("MyTag").value

if selectONE==1:
	system.nav.openWindow('ThisPopup')
	system.nav.centerWindow('ThisPopup')
else:
	system.nav.openWindow('ThatPopup')
	system.nav.centerWindow('ThatPopup')
```

---

<div class="post-metadata">

**Author:** ![tpenke63](https://avatars.discourse-cdn.com/v4/letter/t/5fc32e/32.png) [@tpenke63](https://forum.inductiveautomation.com/u/tpenke63)\
**Post date:** [January 6, 2014, 10:58pm UTC](https://forum.inductiveautomation.com/t/how-to-open-a-popup-based-on-tag-value/7574/17 "2014-01-06T22:58:47Z")

</div>

Thanks for the advice… I did a Homer Simpson on the Python ==. In any case - still errors out on me:

[attachment=0]Error.jpg[/attachment]

There’s probably another way to skin the cat 😮

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [January 6, 2014, 11:10pm UTC](https://forum.inductiveautomation.com/t/how-to-open-a-popup-based-on-tag-value/7574/18 "2014-01-06T23:10:34Z")

</div>

Hi,  
You have a simple Python syntax error. You have a couple spaces in front of “if AerationSelect==1:” that needs to be removed.

You need to make sure that the spacing and indentation of the Python code is correct.

Best,  
Nick

---

<div class="post-metadata">

**Author:** ![adamaustin](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@adamaustin](https://forum.inductiveautomation.com/u/adamaustin)\
**Post date:** [January 6, 2014, 11:15pm UTC](https://forum.inductiveautomation.com/t/how-to-open-a-popup-based-on-tag-value/7574/19 "2014-01-06T23:15:17Z")

</div>

```auto
# Open pop-up based on whether B8700S is selected for Membrane or Bio aeration
#
# Start script - assign alias to tag
AerationSelect=system.tag.read("CSWT1MB/BLOWERS/Global_Blower_Setpoints/pbB8700S_Membrane_Aeration_Select").value
# Check alias value
if AerationSelect==1:
	# If aliased tag = 1 then B8700S Selected for Membrane Aeration - open Train Blower pop-up populated with B8700S info
	system.nav.openWindow('Program Windows/Popups/puTrainBlower', {'BlowerID' : 'B8700S_HMI', 'TagPath' : 'B8700S_Info', 'TagID' : 'B8700S_Control'})
	system.nav.centerWindow('Program Windows/Popups/puTrainBlower')
else:
	# else B8700S Selected for Bio Aeration - open MBR Blower pop-up populated with B8700S info
	system.nav.openWindow('Program Windows/Popups/puMBRBlower', {'BlowerID' : 'B8700S_HMI', 'TagPath' : 'B8700S_Info', 'TagID' : 'B8700S_Control'})
	system.nav.centerWindow('Program Windows/Popups/puMBRBlower')
```

---

<div class="post-metadata">

**Author:** ![adamaustin](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@adamaustin](https://forum.inductiveautomation.com/u/adamaustin)\
**Post date:** [January 6, 2014, 11:22pm UTC](https://forum.inductiveautomation.com/t/how-to-open-a-popup-based-on-tag-value/7574/20 "2014-01-06T23:22:34Z")

</div>

The word SyntaxError means that you wrote some code wrong. (In this case, it was the [indentation](http://www.diveintopython.net/getting_to_know_python/indenting_code.html) on line 6) You’ll get it eventually; it just takes time if you’re new to this sort of thing.

[Next page](https://forum.inductiveautomation.com/t/how-to-open-a-popup-based-on-tag-value/7574.md?page=2)
