# Perspective - Use tag to open popup

**URL:** <https://forum.inductiveautomation.com/t/perspective-use-tag-to-open-popup/100016>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [December 18, 2024, 11:12pm UTC](https://forum.inductiveautomation.com/t/perspective-use-tag-to-open-popup/100016 "2024-12-18T23:12:01Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Long\_Vang](https://avatars.discourse-cdn.com/v4/letter/l/bcef8e/32.png) [@Long\_Vang](https://forum.inductiveautomation.com/u/Long_Vang)\
**Post date:** [December 18, 2024, 11:12pm UTC](https://forum.inductiveautomation.com/t/perspective-use-tag-to-open-popup/100016/1 "2024-12-18T23:12:01Z")

</div>

Hello,

I want to show a popup when one of my tag is true.

I've tried binding the tag to ta custom property in a view screen and then do a under a change script: I added just: system.perspective.openpop(viewpath). By doing so, when I turn on the bool, I got an error.

I would appreciate any feedback you guys have.

---

<div class="post-metadata">

**Author:** ![Long\_Vang](https://avatars.discourse-cdn.com/v4/letter/l/bcef8e/32.png) [@Long\_Vang](https://forum.inductiveautomation.com/u/Long_Vang)\
**Post date:** [December 18, 2024, 11:14pm UTC](https://forum.inductiveautomation.com/t/perspective-use-tag-to-open-popup/100016/2 "2024-12-18T23:14:35Z")

</div>

I also try adding this to the tag:

```
popupId = "checklist123456"
viewPath = "Popup/Checklist" # insert your view path here
logger = system.util.getLogger("POPUP")
sessions = system.perspective.getSessionInfo()
for session in sessions:
    for pageId in session.pageIds:
        logger.info("{0} | {1}".format(session.id, pageId))
        if session.userAgent != "<designer>":
            if currentValue.value:
                system.perspective.openPopup(popupId, viewPath, sessionId=session.id, pageId=pageId)
            else:
                # note no viewPath arg
                system.perspective.closePopup(popupId, sessionId=session.id, pageId=pageId)

```

This works but it requires the user to have gateway homepage browser to be on in the background and the designer.

---

<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:** [December 18, 2024, 11:15pm UTC](https://forum.inductiveautomation.com/t/perspective-use-tag-to-open-popup/100016/3 "2024-12-18T23:15:48Z")

</div>

> [@Long\_Vang](#):
>
> I got an error.

What is the error?

> [@Long\_Vang](#):
>
> I also try adding this to the tag:

Don't do this. Your first instinct was correct.

---

<div class="post-metadata">

**Author:** ![Long\_Vang](https://avatars.discourse-cdn.com/v4/letter/l/bcef8e/32.png) [@Long\_Vang](https://forum.inductiveautomation.com/u/Long_Vang)\
**Post date:** [December 18, 2024, 11:16pm UTC](https://forum.inductiveautomation.com/t/perspective-use-tag-to-open-popup/100016/4 "2024-12-18T23:16:51Z")

</div>

Error is:

Error running property change script on view.custom.OpenPopup: Traceback (most recent call last): File "function:valueChanged", line 3, in valueChanged at com.inductiveautomation.perspective.gateway.script.PerspectiveScriptingFunctions.openPopup(PerspectiveScriptingFunctions.java:238) at jdk.internal.reflect.GeneratedMethodAccessor57.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: 'view' argument must be provided.

---

<div class="post-metadata">

**Author:** ![Long\_Vang](https://avatars.discourse-cdn.com/v4/letter/l/bcef8e/32.png) [@Long\_Vang](https://forum.inductiveautomation.com/u/Long_Vang)\
**Post date:** [December 18, 2024, 11:18pm UTC](https://forum.inductiveautomation.com/t/perspective-use-tag-to-open-popup/100016/5 "2024-12-18T23:18:55Z")

</div>

com.inductiveautomation.ignition.common.script.JythonExecException  
Traceback (most recent call last):  
File "function:valueChanged", line 2, in valueChanged  
java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: 'view' argument must be provided.

```
caused by org.python.core.PyException

```

Traceback (most recent call last):  
File "function:valueChanged", line 2, in valueChanged  
java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: 'view' argument must be provided.

```
caused by IllegalArgumentException: 'view' argument must be provided.

```

Ignition v8.1.33 (b2023101913)  
Java: Azul Systems, Inc. 17.0.8

---

<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:** [December 18, 2024, 11:22pm UTC](https://forum.inductiveautomation.com/t/perspective-use-tag-to-open-popup/100016/6 "2024-12-18T23:22:25Z")

</div>

I get the gist; can you post the _exact_ script you had in the property change script on the session custom property?

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [December 18, 2024, 11:23pm UTC](https://forum.inductiveautomation.com/t/perspective-use-tag-to-open-popup/100016/7 "2024-12-18T23:23:14Z")

</div>

Post the error as preformatted text to make it easier to read, please see [Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831).

You need to bind the tag you want to watch/trigger the popup to a custom property on either your perspective session or view, and then use a value changed script on that property to open the popup.

If you bind on the session property, you'll need to use a message handler to send an open window message to the currently open view, which will need to have the associated message handler defined.

---

<div class="post-metadata">

**Author:** ![Long\_Vang](https://avatars.discourse-cdn.com/v4/letter/l/bcef8e/32.png) [@Long\_Vang](https://forum.inductiveautomation.com/u/Long_Vang)\
**Post date:** [December 18, 2024, 11:23pm UTC](https://forum.inductiveautomation.com/t/perspective-use-tag-to-open-popup/100016/8 "2024-12-18T23:23:59Z")

</div>

sure. It just this:

def valueChanged(self, previousValue, currentValue, origin, missedEvents):  
system.perspective.openPopup("Popup/Checklist")

I didn't want go further if this doesn't work.

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [December 18, 2024, 11:25pm UTC](https://forum.inductiveautomation.com/t/perspective-use-tag-to-open-popup/100016/9 "2024-12-18T23:25:46Z")

</div>

> [@Show a popup in perspective on all clients if a value changes](https://forum.inductiveautomation.com/t/show-a-popup-in-perspective-on-all-clients-if-a-value-changes/61133):
>
> In perspective I have a popup page that I want to show up on all screens in the network if a certain tag is set to true. How would I go about doing that and what would that script look like? thank you

---

<div class="post-metadata">

**Author:** ![Long\_Vang](https://avatars.discourse-cdn.com/v4/letter/l/bcef8e/32.png) [@Long\_Vang](https://forum.inductiveautomation.com/u/Long_Vang)\
**Post date:** [December 18, 2024, 11:25pm UTC](https://forum.inductiveautomation.com/t/perspective-use-tag-to-open-popup/100016/10 "2024-12-18T23:25:48Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/e/4e8292f7d404418d1263a2461d498de2f1a302c9.png)

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [December 18, 2024, 11:32pm UTC](https://forum.inductiveautomation.com/t/perspective-use-tag-to-open-popup/100016/11 "2024-12-18T23:32:36Z")

</div>

> [@Long\_Vang](#):
>
> def valueChanged(self, previousValue, currentValue, origin, missedEvents):  
> system.perspective.openPopup("Popup/Checklist")

Please put all code as formatted text so it's easier to read/retains indentation.

You are not providing the required arguments to [`system.perspective.openPopup`](https://www.docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-perspective/system-perspective-openPopup).

You need to supply a popup Id as well as the path to the popup view.

```python
def valueChanged(self, previousValue, currentValue, origin, missedEvents):
	if (not previousValue or not previousValue.value) and currentValue.value:
		system.perspective.openPopup("_pChecklist", "Popup/Checklist")

```

---

<div class="post-metadata">

**Author:** ![Long\_Vang](https://avatars.discourse-cdn.com/v4/letter/l/bcef8e/32.png) [@Long\_Vang](https://forum.inductiveautomation.com/u/Long_Vang)\
**Post date:** [December 19, 2024, 1:51am UTC](https://forum.inductiveautomation.com/t/perspective-use-tag-to-open-popup/100016/12 "2024-12-19T01:51:41Z")

</div>

Thanks Mate. Got it to open the popup. How about when the tag goes to false and close out the popup? I tried the else statement but that doesn't seem to work.

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [December 19, 2024, 2:08am UTC](https://forum.inductiveautomation.com/t/perspective-use-tag-to-open-popup/100016/13 "2024-12-19T02:08:37Z")

</div>

```python
def valueChanged(self, previousValue, currentValue, origin, missedEvents):
	if (not previousValue or not previousValue.value) and currentValue.value:
		system.perspective.openPopup("_pChecklist", "Popup/Checklist")
	
	elif (not previousValue or previousValue.value) and not currentValue.value:
		system.perspective.closePopup("_pChecklist")

```

---

<div class="post-metadata">

**Author:** ![Long\_Vang](https://avatars.discourse-cdn.com/v4/letter/l/bcef8e/32.png) [@Long\_Vang](https://forum.inductiveautomation.com/u/Long_Vang)\
**Post date:** [December 19, 2024, 2:10am UTC](https://forum.inductiveautomation.com/t/perspective-use-tag-to-open-popup/100016/14 "2024-12-19T02:10:42Z")

</div>

Thanks Mate!
