# Triggering popup

**URL:** <https://forum.inductiveautomation.com/t/triggering-popup/89736>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [April 30, 2024, 8:32pm UTC](https://forum.inductiveautomation.com/t/triggering-popup/89736 "2024-04-30T20:32:35Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nathaniel\_Webb](https://avatars.discourse-cdn.com/v4/letter/n/e8c25b/32.png) [@Nathaniel\_Webb](https://forum.inductiveautomation.com/u/Nathaniel_Webb)\
**Post date:** [April 30, 2024, 8:32pm UTC](https://forum.inductiveautomation.com/t/triggering-popup/89736/1 "2024-04-30T20:32:36Z")

</div>

I have tag S201\_Run. I would like for it to trigger a popup to open if remains false for at least 15 minutes. The popup view is called "Senntech 201 Popup". The view for the popup to appear on is called "Senntech 201". I have tried using a gateway event script and the function:

```python
system.perspective.openPopup("Machine Downtime windows/Senntech 201 Popup view", "Machine Downtime windows/Senntech 201")

```

How do i accomplish this if nothing has worked.

---

<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:** [April 30, 2024, 8:59pm UTC](https://forum.inductiveautomation.com/t/triggering-popup/89736/2 "2024-04-30T20:59:30Z")

</div>

You have to split your task into the parts that need to run all the time (timing) from the parts that run in your user interface.

First, make a memory tag of type datetime to hold the timestamp when the tag of interest changed to false. Use a value change script on the boolean tag that checks if does nothing on initial change, but writes the timestamp from `system.date.now()` when `not currentValue.value`.

Then, in your perspective UI, probably in a docked view appropriate to your application, bind both the boolean and the timestamp tags to custom properties. Add another custom property with an expression binding that computes `timeBetween()` now and that timestamp. Use a valueChange on that to trigger your popup.

---

<div class="post-metadata">

**Author:** ![Nathaniel\_Webb](https://avatars.discourse-cdn.com/v4/letter/n/e8c25b/32.png) [@Nathaniel\_Webb](https://forum.inductiveautomation.com/u/Nathaniel_Webb)\
**Post date:** [May 15, 2024, 9:48pm UTC](https://forum.inductiveautomation.com/t/triggering-popup/89736/3 "2024-05-15T21:48:46Z")

</div>

So, i have gotten everything to work, but the popup.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/b/4b805d3ac35479911a992cdfec301b78d1116c3d.png)  
How do I get the popupTrigger parameter value to open a popup. I currently can toggle my popup using an on click popup event on the "Downtime reason" button.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/1/3147218c20d12eb61586d9e6df56c807dc17dffa.jpeg)

---

<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:** [May 15, 2024, 9:52pm UTC](https://forum.inductiveautomation.com/t/triggering-popup/89736/4 "2024-05-15T21:52:20Z")

</div>

You would use a value change event script on the popup trigger boolean property.

---

<div class="post-metadata">

**Author:** ![Nathaniel\_Webb](https://avatars.discourse-cdn.com/v4/letter/n/e8c25b/32.png) [@Nathaniel\_Webb](https://forum.inductiveautomation.com/u/Nathaniel_Webb)\
**Post date:** [May 16, 2024, 12:36pm UTC](https://forum.inductiveautomation.com/t/triggering-popup/89736/5 "2024-05-16T12:36:52Z")

</div>

Hello, that makes a lot of sense. What kind of script is that and where do I put it? It is not something I am familiar with. I mainly ask, because I see no way of putting a value change event script on a property. I am currently using the timeElapsed to count the time since it has stopped. the popupTrigger property is then output true or false depending on the amount of time it has been off.

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

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [May 16, 2024, 12:39pm UTC](https://forum.inductiveautomation.com/t/triggering-popup/89736/6 "2024-05-16T12:39:20Z")

</div>

Just a comment on the expression. It can be simplified to  
`{view.custom.timeElapsed} >= 15`

That will be either `true` or `false` and that will be the result of the expression. No `if` required.

* * *

For the change event,

- Right-click on `view.custom.popupTrigger`.
- Select "Add Change Script".

You should consider making the popup background dismissable. The user can then click anywhere outside the popup to have it disappear. It's much easier than trying to hit the X or Close button.

---

<div class="post-metadata">

**Author:** ![Nathaniel\_Webb](https://avatars.discourse-cdn.com/v4/letter/n/e8c25b/32.png) [@Nathaniel\_Webb](https://forum.inductiveautomation.com/u/Nathaniel_Webb)\
**Post date:** [May 16, 2024, 12:57pm UTC](https://forum.inductiveautomation.com/t/triggering-popup/89736/7 "2024-05-16T12:57:21Z")

</div>

would this work?

```python
# Property change script for the popupTrigger property
def valueChanged(self, previousValue, currentValue, origin, missedEvents):
    # Check if the property value changes to true
    if currentValue:
        # Get a reference to the current view
        view = self.view

        # Open the popup when the property value changes to true
        system.perspective.openPopup(viewPath="Machine Downtime windows/Senntech 201 Popup", target=view)

```

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [May 16, 2024, 1:02pm UTC](https://forum.inductiveautomation.com/t/triggering-popup/89736/8 "2024-05-16T13:02:32Z")

</div>

Maybe this topic will be helpful for you? If you trigger from a tag, you will need to get the session and page.

> [@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/18):
>
> When I run the following code: def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents): popupId = "O2Alarm" viewPath = "Split" # 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 currentValue and currentValue.value: # I added an additional safety check for first time use he…

---

<div class="post-metadata">

**Author:** ![Nathaniel\_Webb](https://avatars.discourse-cdn.com/v4/letter/n/e8c25b/32.png) [@Nathaniel\_Webb](https://forum.inductiveautomation.com/u/Nathaniel_Webb)\
**Post date:** [May 16, 2024, 1:04pm UTC](https://forum.inductiveautomation.com/t/triggering-popup/89736/9 "2024-05-16T13:04:59Z")

</div>

I am attempting to open a popup in only one view. I'm not sure that this topic is similar.

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [May 16, 2024, 1:08pm UTC](https://forum.inductiveautomation.com/t/triggering-popup/89736/10 "2024-05-16T13:08:48Z")

</div>

> [@Nathaniel\_Webb](#):
>
> ```python
> # Check if the property value changes to true
> if currentValue:
> 
> ```

It's a qualified value so, `currentValue.value`.

Sorry, didn't read the entire topic, just made some assumptions.

---

<div class="post-metadata">

**Author:** ![Nathaniel\_Webb](https://avatars.discourse-cdn.com/v4/letter/n/e8c25b/32.png) [@Nathaniel\_Webb](https://forum.inductiveautomation.com/u/Nathaniel_Webb)\
**Post date:** [May 16, 2024, 1:22pm UTC](https://forum.inductiveautomation.com/t/triggering-popup/89736/11 "2024-05-16T13:22:42Z")

</div>

Unfortunately, I keep getting this error no matter what i do.

```python
com.inductiveautomation.ignition.common.script.JythonExecException
Traceback (most recent call last):
  File "<function:valueChanged>", line 8, 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 8, in valueChanged
java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: 'view' argument must be provided.

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

Ignition v8.1.32 (b2023091211)
Java: Azul Systems, Inc. 11.0.18

```

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [May 16, 2024, 1:27pm UTC](https://forum.inductiveautomation.com/t/triggering-popup/89736/12 "2024-05-16T13:27:25Z")

</div>

> [@Nathaniel\_Webb](#):
>
> `... 201 Popup", target = view)`

[system.perspective.openPopup | Ignition User Manual](https://docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-perspective/system-perspective-openPopup#syntax) doesn't have a `target` parameter.

---

<div class="post-metadata">

**Author:** ![Nathaniel\_Webb](https://avatars.discourse-cdn.com/v4/letter/n/e8c25b/32.png) [@Nathaniel\_Webb](https://forum.inductiveautomation.com/u/Nathaniel_Webb)\
**Post date:** [May 16, 2024, 2:05pm UTC](https://forum.inductiveautomation.com/t/triggering-popup/89736/13 "2024-05-16T14:05:44Z")

</div>

```python
def valueChanged(self, previousValue, currentValue, origin, missedEvents):
    # Check if the property value changes to true
    if currentValue.value:
        # Open the popup when the property value changes to true
        system.perspective.openPopup(
            id="popupId",
            view="Machine Downtime windows/Senntech 201 Popup",
            title="Popup Title",
            position={"left": 100, "top": 100},
            showCloseIcon=True
        )

```

I am getting much closer. I am no longer getting errors, but am still not seeing a popup.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [May 16, 2024, 2:12pm UTC](https://forum.inductiveautomation.com/t/triggering-popup/89736/14 "2024-05-16T14:12:18Z")

</div>

1. You need to be testing this in the browser. Designer won't display popups.
2. If you're doing that already then it's time to start digging in the logs, I'm afraid. Gateway | Status | DIAGNOSTICS | Logs.

---

<div class="post-metadata">

**Author:** ![Nathaniel\_Webb](https://avatars.discourse-cdn.com/v4/letter/n/e8c25b/32.png) [@Nathaniel\_Webb](https://forum.inductiveautomation.com/u/Nathaniel_Webb)\
**Post date:** [May 16, 2024, 2:17pm UTC](https://forum.inductiveautomation.com/t/triggering-popup/89736/15 "2024-05-16T14:17:44Z")

</div>

Thank you. Do you think I need to include the view that it will be open with,

```python
pageId=self.page.pageId

```

I'm not sure if I should be using sessionId or pageId.

---

<div class="post-metadata">

**Author:** ![Nathaniel\_Webb](https://avatars.discourse-cdn.com/v4/letter/n/e8c25b/32.png) [@Nathaniel\_Webb](https://forum.inductiveautomation.com/u/Nathaniel_Webb)\
**Post date:** [May 16, 2024, 2:20pm UTC](https://forum.inductiveautomation.com/t/triggering-popup/89736/16 "2024-05-16T14:20:46Z")

</div>

I did test this popup script in the event script action and it functions when I click a button.

```python
def runAction(self, event):
    system.perspective.openPopup(
	    id="manualTestPopup",
	    view="Machine Downtime windows/Senntech 201 Popup",
	    title="Manual Test Popup",
	    position={"left": 100, "top": 100},
	    showCloseIcon=True,
	    
	)

```

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [May 16, 2024, 2:26pm UTC](https://forum.inductiveautomation.com/t/triggering-popup/89736/17 "2024-05-16T14:26:34Z")

</div>

> [@Nathaniel\_Webb](#):
>
> but am still not seeing a popup.

Perhaps use a `logger` or `print` to make sure the event is working.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [May 16, 2024, 2:29pm UTC](https://forum.inductiveautomation.com/t/triggering-popup/89736/18 "2024-05-16T14:29:42Z")

</div>

Good. Code should be OK then.

Let's step back a bit. The thread has got a bit long. Please confirm or correct:

1. You're using a custom property `popupTrigger`.
2. `popupTrigger` is a custom property of a view and you only expect the popup to work if this view happens to be open.
3. You have the valueChanged script on `custom.popupTrigger`.

One other trick to speed up testing: Add a checkbox to the view. Create the same valueChanged script onto the checkbox `selected` property. You can then toggle it for testing without any time delay.

---

<div class="post-metadata">

**Author:** ![Nathaniel\_Webb](https://avatars.discourse-cdn.com/v4/letter/n/e8c25b/32.png) [@Nathaniel\_Webb](https://forum.inductiveautomation.com/u/Nathaniel_Webb)\
**Post date:** [May 16, 2024, 2:37pm UTC](https://forum.inductiveautomation.com/t/triggering-popup/89736/19 "2024-05-16T14:37:47Z")

</div>

1. the custom property popupTrigger is correct
2. That is correct
3. the value changed script is on the custom.popupTrigger

I have button, but I will try this.  
Other details:

1. The popup is on its own view.
2. the popupTrigger is either true or false, bound to my custom.timeElapsed property

here is the code once again:

```python
def valueChanged(self, previousValue, currentValue, origin, missedEvents):
    # Check if the property value changes to true
    if currentValue.value:
        # Open the popup when the property value changes to true
        system.perspective.openPopup(
            id="popupId",
            view="Machine Downtime windows/Senntech 201 Popup",
            title="Popup Title",
            position={"left": 100, "top": 100},
            showCloseIcon=True,
            
        )

```

---

<div class="post-metadata">

**Author:** ![Nathaniel\_Webb](https://avatars.discourse-cdn.com/v4/letter/n/e8c25b/32.png) [@Nathaniel\_Webb](https://forum.inductiveautomation.com/u/Nathaniel_Webb)\
**Post date:** [May 16, 2024, 2:39pm UTC](https://forum.inductiveautomation.com/t/triggering-popup/89736/20 "2024-05-16T14:39:15Z")

</div>

The check box works

[Next page](https://forum.inductiveautomation.com/t/triggering-popup/89736.md?page=2)
