# Time dependent popup

**URL:** <https://forum.inductiveautomation.com/t/time-dependent-popup/58665>\
**Category:** Ignition\
**Created:** [April 21, 2022, 7:46am UTC](https://forum.inductiveautomation.com/t/time-dependent-popup/58665 "2022-04-21T07:46:48Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![mootez\_bh](https://avatars.discourse-cdn.com/v4/letter/m/8e8cbc/32.png) [@mootez\_bh](https://forum.inductiveautomation.com/u/mootez_bh)\
**Post date:** [April 21, 2022, 7:46am UTC](https://forum.inductiveautomation.com/t/time-dependent-popup/58665/1 "2022-04-21T07:46:48Z")

</div>

hello, i want to create a popup screen that apear when a tag value change for more than a defined time period ( lets say when a tag value change for more than 5 min a popup screen appears to the user ). any idea or suggestion could help a lot. thanks in advance

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [April 21, 2022, 4:14pm UTC](https://forum.inductiveautomation.com/t/time-dependent-popup/58665/2 "2022-04-21T16:14:31Z")

</div>

Are you using Vision or Perspective for this?

---

<div class="post-metadata">

**Author:** ![mootez\_bh](https://avatars.discourse-cdn.com/v4/letter/m/8e8cbc/32.png) [@mootez\_bh](https://forum.inductiveautomation.com/u/mootez_bh)\
**Post date:** [April 25, 2022, 12:21pm UTC](https://forum.inductiveautomation.com/t/time-dependent-popup/58665/3 "2022-04-25T12:21:56Z")

</div>

vision

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [April 25, 2022, 6:11pm UTC](https://forum.inductiveautomation.com/t/time-dependent-popup/58665/4 "2022-04-25T18:11:29Z")

</div>

What type of tag do you want to trigger the popup?

I’m thinking you could have an a alarm on that tag, use that to trigger the popup.

---

<div class="post-metadata">

**Author:** ![mootez\_bh](https://avatars.discourse-cdn.com/v4/letter/m/8e8cbc/32.png) [@mootez\_bh](https://forum.inductiveautomation.com/u/mootez_bh)\
**Post date:** [April 26, 2022, 8:25am UTC](https://forum.inductiveautomation.com/t/time-dependent-popup/58665/5 "2022-04-26T08:25:05Z")

</div>

it’s a boolen tag, i wrote this script when there is a value change :

if (previousValue.value == 0 and currentValue.value == 1) :  
starttime= system.date.now()

while true :   
tmp = system.date.now()

```
if datediff(starttime,tmp,"minute") >= 5 :
	system.nav.openWindow("SiteSpecific/fault description")
else : 
	"[.]Fault description tag .value"== "micro arrêt"

```

i still doesn’t know if it works or not

---

<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:** [April 26, 2022, 10:07am UTC](https://forum.inductiveautomation.com/t/time-dependent-popup/58665/6 "2022-04-26T10:07:45Z")

</div>

Can you format the whole code ?

Also, I never used vision, but this seems weird to me:

> [@mootez\_bh](#):
>
> `"[.]Fault description tag .value"== "micro arrêt"`

first, you're using `==`, which is a comparison operator. Probably not what you want to do.  
Also, both operands are strings.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [April 26, 2022, 12:01pm UTC](https://forum.inductiveautomation.com/t/time-dependent-popup/58665/7 "2022-04-26T12:01:02Z")

</div>

As @pascal.fragnoud has pointed out, your script has syntatical errors in it.

this:

```auto
"[.]Fault description tag .value"== "micro arrêt"

```

is not how you write a value to a tag.

To write a value to a tag you need something like:

```auto
system.tag.writeBlocking(['[.]Fault description tag'],['micro arrêt'])

```

You have bigger problems with this script though, from what I can tell this is a Tag Value Change script, and doing this:

```auto
while true:

```

Is bad to say the least. Not only is it poor programming practice in general, but even without properly formatted code you have shown no way for the code to break out of the loop. You have created an infinite loop in a place where you want your scripts to execute as quickly as possible.

The dragons are circling.

---

<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:** [April 26, 2022, 12:18pm UTC](https://forum.inductiveautomation.com/t/time-dependent-popup/58665/8 "2022-04-26T12:18:17Z")

</div>

Think of the Ignition Environment firing off the tag changes as the `while True`. Ignition will run the script when it is supposed to (assuming you have your tags set up correctly). But ultimately inside Ignition you never want a `while True` without some `break` condition.

Since this is just a boolean tag (and thus it staying True for 5 minutes is not going to trigger an additional tag event) you might want to consider a Gateway Timer Event that checks if the tag is True and then compares the timestamp of the tag ( which is when it last changed) to the current time - then you can see if it’s been more than 5 minutes, and if so, then you can have your gateway send a message to your client(s) to open up a popup window.

I think there may also be a way to do this via an alarm - have an alarm trigger if the value is True for more than 5 minutes and if so, run a script. But I am not as familiar with this perhaps someone else can speak on it.

---

<div class="post-metadata">

**Author:** ![zxcslo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zxcslo/32/61610_2.png) [@zxcslo](https://forum.inductiveautomation.com/u/zxcslo)\
**Post date:** [April 26, 2022, 12:39pm UTC](https://forum.inductiveautomation.com/t/time-dependent-popup/58665/9 "2022-04-26T12:39:28Z")

</div>

In the `Alarm Active` event, you don’t have access to `system.nav.*` functions…  
Like `window = system.nav.openWindow('PopupWindow')`

Gateway Timer Event is the best option… as @bkarabinchak.psi suggested…

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [April 26, 2022, 12:48pm UTC](https://forum.inductiveautomation.com/t/time-dependent-popup/58665/10 "2022-04-26T12:48:35Z")

</div>

> [@zxcslo](#):
>
> In the `Alarm Active` event, you don’t have access to `system.nav.*` functions…  
> Like `window = system.nav.openWindow('PopupWindow')`

Oh, I missed that!

An infinite loop on the UI thread is possibly even worse than one on a tag change script.

---

<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:** [April 26, 2022, 12:50pm UTC](https://forum.inductiveautomation.com/t/time-dependent-popup/58665/11 "2022-04-26T12:50:55Z")

</div>

How about an expression memory tag with something like

```auto
{[.]boolean_tag}
&& minutesBetween({[.]boolean_tag.timestamp}, now()) > 5

```

then trigger the popup on tag change ?

---

<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 26, 2022, 12:56pm UTC](https://forum.inductiveautomation.com/t/time-dependent-popup/58665/12 "2022-04-26T12:56:30Z")

</div>

> [@lrose](#):
>
> An infinite loop on the UI thread is possibly even worse than one on a tag change script.

Nah. Freezing the client kills just the one client. Bollixing up all of your tag event scripts will bring your entire system to a halt.

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [April 26, 2022, 2:27pm UTC](https://forum.inductiveautomation.com/t/time-dependent-popup/58665/13 "2022-04-26T14:27:13Z")

</div>

Just a tip, if your question involves code and you already have something written. You will get much better help/response time by posting relevant code right off the bat.

---

<div class="post-metadata">

**Author:** ![Vinodhini\_N](https://avatars.discourse-cdn.com/v4/letter/v/65b543/32.png) [@Vinodhini\_N](https://forum.inductiveautomation.com/u/Vinodhini_N)\
**Post date:** [January 10, 2024, 5:02am UTC](https://forum.inductiveautomation.com/t/time-dependent-popup/58665/14 "2024-01-10T05:02:43Z")

</div>

i have same doubt in perspective? is any option available

---

<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:** [January 10, 2024, 9:45am UTC](https://forum.inductiveautomation.com/t/time-dependent-popup/58665/15 "2024-01-10T09:45:19Z")

</div>

Please start your own thread, tag it as Perspective, explain clearly what your question is and if posting code then format it properly.
