# Perspective scripts triggers twice

**URL:** <https://forum.inductiveautomation.com/t/perspective-scripts-triggers-twice/106757>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [May 28, 2025, 8:59am UTC](https://forum.inductiveautomation.com/t/perspective-scripts-triggers-twice/106757 "2025-05-28T08:59:14Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amitkumar\_Ravat1](https://avatars.discourse-cdn.com/v4/letter/a/b5a626/32.png) [@Amitkumar\_Ravat1](https://forum.inductiveautomation.com/u/Amitkumar_Ravat1)\
**Post date:** [May 28, 2025, 8:59am UTC](https://forum.inductiveautomation.com/t/perspective-scripts-triggers-twice/106757/1 "2025-05-28T08:59:14Z")

</div>

I have a single workstation screen that is dynamic and open on workstation based on IP assigned to workstation. So, at one of the station multiple tabs with same workstation was opened so some scripts were triggered multiple time this has happened previous, so we use to close the other tabs then the everything starts working fine but now after closing also multiple triggers are received after gateway restart all things settles down. How we resolve this issue permanently?  
Thanks for the support

---

<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:** [May 28, 2025, 9:55am UTC](https://forum.inductiveautomation.com/t/perspective-scripts-triggers-twice/106757/2 "2025-05-28T09:55:32Z")

</div>

Well... what's the trigger for this script ? Is it a gateway event ? A value change ? Something else ?  
There's not much we can do to help without more details.

---

<div class="post-metadata">

**Author:** ![Amitkumar\_Ravat1](https://avatars.discourse-cdn.com/v4/letter/a/b5a626/32.png) [@Amitkumar\_Ravat1](https://forum.inductiveautomation.com/u/Amitkumar_Ravat1)\
**Post date:** [May 28, 2025, 10:08am UTC](https://forum.inductiveautomation.com/t/perspective-scripts-triggers-twice/106757/3 "2025-05-28T10:08:49Z")

</div>

we have some custom params on root inside that we have value change script

---

<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:** [May 28, 2025, 1:40pm UTC](https://forum.inductiveautomation.com/t/perspective-scripts-triggers-twice/106757/4 "2025-05-28T13:40:40Z")

</div>

> [@Amitkumar\_Ravat1](#):
>
> multiple tabs with same workstation was opened

Multiple "tabs"? As in, you somehow were able to open two tab container tabs at once? That is technically impossible.

Correct terminology is crucial for our understanding. If you mean Views, say Views. If you mean perspective clients, say perspective clients. Etc

---

<div class="post-metadata">

**Author:** ![Amitkumar\_Ravat1](https://avatars.discourse-cdn.com/v4/letter/a/b5a626/32.png) [@Amitkumar\_Ravat1](https://forum.inductiveautomation.com/u/Amitkumar_Ravat1)\
**Post date:** [May 28, 2025, 3:49pm UTC](https://forum.inductiveautomation.com/t/perspective-scripts-triggers-twice/106757/5 "2025-05-28T15:49:35Z")

</div>

I meant Multiple browser tabs. I can say same view were opened in the two different tabs.

---

<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 28, 2025, 3:54pm UTC](https://forum.inductiveautomation.com/t/perspective-scripts-triggers-twice/106757/6 "2025-05-28T15:54:54Z")

</div>

I'm not sure what you expect to happen when two user interfaces are open, and have the same scripts. Why **wouldn't** they run for both clients?

If you want scripts to run once regardless of how many user interfaces are open, use gateway events.

If you want scripts that run once for a single browser, no matter how many browser tabs are open, use session events.

---

<div class="post-metadata">

**Author:** ![Amitkumar\_Ravat1](https://avatars.discourse-cdn.com/v4/letter/a/b5a626/32.png) [@Amitkumar\_Ravat1](https://forum.inductiveautomation.com/u/Amitkumar_Ravat1)\
**Post date:** [May 28, 2025, 4:04pm UTC](https://forum.inductiveautomation.com/t/perspective-scripts-triggers-twice/106757/7 "2025-05-28T16:04:46Z")

</div>

On custom params have opc tag bindings so when i am receiving values from OPC tags it triggers my script twice.

---

<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 28, 2025, 4:07pm UTC](https://forum.inductiveautomation.com/t/perspective-scripts-triggers-twice/106757/8 "2025-05-28T16:07:24Z")

</div>

Yeah, expected behavior. View parameters are **user-interface** elements. If you need machine-triggered operations, those do not belong in user interfaces.

---

<div class="post-metadata">

**Author:** ![Amitkumar\_Ravat1](https://avatars.discourse-cdn.com/v4/letter/a/b5a626/32.png) [@Amitkumar\_Ravat1](https://forum.inductiveautomation.com/u/Amitkumar_Ravat1)\
**Post date:** [May 28, 2025, 4:10pm UTC](https://forum.inductiveautomation.com/t/perspective-scripts-triggers-twice/106757/9 "2025-05-28T16:10:06Z")

</div>

so, i have multiple browser tabs opened so it was triggering multiple time as expected but now those tabs are closed only single tabs is opened but still script is running twice. after gateway restart it is resolved and again this repeat on some stations.

---

<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 28, 2025, 4:11pm UTC](https://forum.inductiveautomation.com/t/perspective-scripts-triggers-twice/106757/10 "2025-05-28T16:11:45Z")

</div>

Browsers don't always tell a webserver that a given browser tab was closed. Nothing Ignition can do about that. Refactor your application to put such scripts in gateway or session events.

---

<div class="post-metadata">

**Author:** ![Amitkumar\_Ravat1](https://avatars.discourse-cdn.com/v4/letter/a/b5a626/32.png) [@Amitkumar\_Ravat1](https://forum.inductiveautomation.com/u/Amitkumar_Ravat1)\
**Post date:** [May 28, 2025, 4:14pm UTC](https://forum.inductiveautomation.com/t/perspective-scripts-triggers-twice/106757/11 "2025-05-28T16:14:05Z")

</div>

So what about session params? will they so behave same when brower tabs are closed?

---

<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 28, 2025, 4:18pm UTC](https://forum.inductiveautomation.com/t/perspective-scripts-triggers-twice/106757/12 "2025-05-28T16:18:07Z")

</div>

Session params won't generate duplicate events. But events might fire long after the last tab is closed--again because browsers don't tell webservers when tabs are closed.

You haven't shared anything about what the script is doing, so I cannot even advise where this script belongs. I can only make very general recommendations. You will have to share much more detail to get better advice from us here on the forum.

---

<div class="post-metadata">

**Author:** ![Amitkumar\_Ravat1](https://avatars.discourse-cdn.com/v4/letter/a/b5a626/32.png) [@Amitkumar\_Ravat1](https://forum.inductiveautomation.com/u/Amitkumar_Ravat1)\
**Post date:** [May 28, 2025, 4:23pm UTC](https://forum.inductiveautomation.com/t/perspective-scripts-triggers-twice/106757/13 "2025-05-28T16:23:48Z")

</div>

So here after receiving a value from OPC tag we have some custom logic that after execution writes again on other OPC tag.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/optimized/3X/f/c/fcb9058a3d1db11e10c96c7e8cfeb48b0153f849_2_690x30.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/7/078b30802042928bb5167ab35757db31f15a8e4e.png)  
In the above snapshot is the log file where we are writing during execution of the script

---

<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 28, 2025, 4:24pm UTC](https://forum.inductiveautomation.com/t/perspective-scripts-triggers-twice/106757/14 "2025-05-28T16:24:51Z")

</div>

Sounds like something that belongs in a gateway tag change event, not in a user interface.

---

<div class="post-metadata">

**Author:** ![Amitkumar\_Ravat1](https://avatars.discourse-cdn.com/v4/letter/a/b5a626/32.png) [@Amitkumar\_Ravat1](https://forum.inductiveautomation.com/u/Amitkumar_Ravat1)\
**Post date:** [May 28, 2025, 4:25pm UTC](https://forum.inductiveautomation.com/t/perspective-scripts-triggers-twice/106757/15 "2025-05-28T16:25:47Z")

</div>

it's not a gateway tag change event it is tag binding on custom params.

---

<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 28, 2025, 4:26pm UTC](https://forum.inductiveautomation.com/t/perspective-scripts-triggers-twice/106757/16 "2025-05-28T16:26:58Z")

</div>

My point is that the code needs to be _ **moved** _ to a more appropriate place in the Ignition project. That kind of operation should not be in any user interface.

---

<div class="post-metadata">

**Author:** ![Amitkumar\_Ravat1](https://avatars.discourse-cdn.com/v4/letter/a/b5a626/32.png) [@Amitkumar\_Ravat1](https://forum.inductiveautomation.com/u/Amitkumar_Ravat1)\
**Post date:** [May 28, 2025, 4:27pm UTC](https://forum.inductiveautomation.com/t/perspective-scripts-triggers-twice/106757/17 "2025-05-28T16:27:46Z")

</div>

ok got it

---

<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:** [May 28, 2025, 10:26pm UTC](https://forum.inductiveautomation.com/t/perspective-scripts-triggers-twice/106757/18 "2025-05-28T22:26:04Z")

</div>

> [@Amitkumar\_Ravat1](#):
>
> .  
> ![image](https://us1.discourse-cdn.com/inductiveautomation/optimized/3X/f/c/fcb9058a3d1db11e10c96c7e8cfeb48b0153f849_2_690x30.png)

Unrelated to the topic, but instead of stringing together multiple indirect references such as here, you should pre-concatenate these into a single custom prop and use the new prop everywhere instead. Otherwise you're just making a lot more work for yourself, especially if something has to change. You can then also guarantee that all places it's used are all the same

Eg  
Expression binding on view.custom.deviceTagPath:  
`"[default]Dewas/" + {view.params.CurrentAreaName} + "/" +`... Etc

Fwiw, I would also be passing in the start as well. Who knows what other project it might end up on. If you design it to be adaptable from the start you will thank yourself

---

<div class="post-metadata">

**Author:** ![Amitkumar\_Ravat1](https://avatars.discourse-cdn.com/v4/letter/a/b5a626/32.png) [@Amitkumar\_Ravat1](https://forum.inductiveautomation.com/u/Amitkumar_Ravat1)\
**Post date:** [May 29, 2025, 3:57am UTC](https://forum.inductiveautomation.com/t/perspective-scripts-triggers-twice/106757/19 "2025-05-29T03:57:41Z")

</div>

Thanks, will look for implementing this as well
