# Change every view on tag change/ Fire alarming

**URL:** <https://forum.inductiveautomation.com/t/change-every-view-on-tag-change-fire-alarming/95382>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [August 30, 2024, 4:34pm UTC](https://forum.inductiveautomation.com/t/change-every-view-on-tag-change-fire-alarming/95382 "2024-08-30T16:34:42Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeff\_Muldoon](https://avatars.discourse-cdn.com/v4/letter/j/ce73a5/32.png) [@Jeff\_Muldoon](https://forum.inductiveautomation.com/u/Jeff_Muldoon)\
**Post date:** [August 30, 2024, 4:34pm UTC](https://forum.inductiveautomation.com/t/change-every-view-on-tag-change-fire-alarming/95382/1 "2024-08-30T16:34:42Z")

</div>

I'm wondering if anyone else has come across the desire to do this, but basically, I'd like one tag to change every view in my project to show a separate view that will have a red background with a label informing everyone to evacuate. I'd also like a second instance that would make a blue background to indicate an ammonia leak and to go to the muster point.

My expression/scripting experience is limited, but I'm willing to work through that, but if someone has experience or some idea on how to best accomplish this, I'd appreciate it

---

<div class="post-metadata">

**Author:** ![kvane](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kvane/32/22228_2.png) [@kvane](https://forum.inductiveautomation.com/u/kvane)\
**Post date:** [August 30, 2024, 6:34pm UTC](https://forum.inductiveautomation.com/t/change-every-view-on-tag-change-fire-alarming/95382/2 "2024-08-30T18:34:59Z")

</div>

This is a feature I have heard being talked about more recently, it is doable but requires scripting. This can be done currently in Perspective using message handlers.

You can setup a Message Handler on the Perspective Session events which likely works for your case. You could take a similar approach on a resource that is perpetually open, for example a navigation view that is permanently docked. Message Handlers can exist almost anywhere such as a Root Container, and will wait and listen for a message to be sent with a matching handler name. When a message is received the handler will trigger the script. In your case you would want the handler script to open a popup or navigate to a view.

> **[Component Message Handlers | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/ignition-modules/perspective/scripting-in-perspective/component-message-handlers)**
>
> In Perspective, Component Message Handlers are the preferred way to pass parameters between components or Views. Doing this involves the system.perspective.sendMessage function. There are typically two steps involved:

You would then need to setup a "trigger" for the message. In your case, based on I assume tag data. So on potentially a Gateway Event \> Tag Change Script, you would then need to add logic to trigger the message send function on all Perspective sessions.

It may look something like this (in addition to logic to only trigger when needed usually an if statement):

```python
# Gets a list of currently running sessions of this project
	runningSessions=system.perspective.getSessionInfo(projectFilter="myProject")

# gets all the designers
	sessions = system.util.getSessionInfo(projectFilter="myProject")
	designerIds = []
	for row in sessions:
		if row["isDesigner"]:
			designerIds.append(row["clientId"])
          
	# Loops through the list of sessions   
	for s in runningSessions:
      
		# if the session is not a designer, send a message (opening a popup, etc)
		if s["id"] not in designerIds:
			for pageID in s["pageIds"]:
				system.perspective.sendMessage(messageType=?, payload=?, [scope="S"], [sessionId=s["id"]], [pageId=PageID])

```

---

<div class="post-metadata">

**Author:** ![Jeff\_Muldoon](https://avatars.discourse-cdn.com/v4/letter/j/ce73a5/32.png) [@Jeff\_Muldoon](https://forum.inductiveautomation.com/u/Jeff_Muldoon)\
**Post date:** [August 30, 2024, 6:48pm UTC](https://forum.inductiveautomation.com/t/change-every-view-on-tag-change-fire-alarming/95382/3 "2024-08-30T18:48:46Z")

</div>

Wow ok. This is definitely at the limits of my skillset, but I'll use your code and try to figure it out. IT would be great if this was a built in feature

---

<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:** [August 30, 2024, 6:51pm UTC](https://forum.inductiveautomation.com/t/change-every-view-on-tag-change-fire-alarming/95382/4 "2024-08-30T18:51:36Z")

</div>

I would use a tag binding in every project's session properties, and a propertyChange event on that. Push both the popup view and the script to run from the propertyChange to the root of your project inheritance tree, if not a single-project environment.

The script would loop through the pages of the session (conveniently available in a session script) firing `system.perspective.openPopup()` on each page. This is much simpler than message sending and receiving scripts.

---

<div class="post-metadata">

**Author:** ![Jeff\_Muldoon](https://avatars.discourse-cdn.com/v4/letter/j/ce73a5/32.png) [@Jeff\_Muldoon](https://forum.inductiveautomation.com/u/Jeff_Muldoon)\
**Post date:** [August 30, 2024, 6:54pm UTC](https://forum.inductiveautomation.com/t/change-every-view-on-tag-change-fire-alarming/95382/5 "2024-08-30T18:54:34Z")

</div>

Ah. So you are thinking make a popup window instead of changing the actual page but would effectively replace it, at least from the end users point of view

---

<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:** [August 30, 2024, 7:01pm UTC](https://forum.inductiveautomation.com/t/change-every-view-on-tag-change-fire-alarming/95382/6 "2024-08-30T19:01:40Z")

</div>

Well, you could also use `system.perspective.navigate()` with each page, but popups are least disruptive (for when the immediate danger clears).

---

<div class="post-metadata">

**Author:** ![Jeff\_Muldoon](https://avatars.discourse-cdn.com/v4/letter/j/ce73a5/32.png) [@Jeff\_Muldoon](https://forum.inductiveautomation.com/u/Jeff_Muldoon)\
**Post date:** [August 30, 2024, 7:02pm UTC](https://forum.inductiveautomation.com/t/change-every-view-on-tag-change-fire-alarming/95382/7 "2024-08-30T19:02:29Z")

</div>

Yeah that makes sense, and could certainly make it large so that its visible.

---

<div class="post-metadata">

**Author:** ![kvane](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kvane/32/22228_2.png) [@kvane](https://forum.inductiveautomation.com/u/kvane)\
**Post date:** [August 30, 2024, 7:04pm UTC](https://forum.inductiveautomation.com/t/change-every-view-on-tag-change-fire-alarming/95382/8 "2024-08-30T19:04:43Z")

</div>

Thanks Phil, this is a much cleaner approach.

---

<div class="post-metadata">

**Author:** ![Jeff\_Muldoon](https://avatars.discourse-cdn.com/v4/letter/j/ce73a5/32.png) [@Jeff\_Muldoon](https://forum.inductiveautomation.com/u/Jeff_Muldoon)\
**Post date:** [August 30, 2024, 9:26pm UTC](https://forum.inductiveautomation.com/t/change-every-view-on-tag-change-fire-alarming/95382/9 "2024-08-30T21:26:10Z")

</div>

whelp I spent the day working on this and didn't succeed. My scripting is severely lacking

---

<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:** [August 30, 2024, 9:40pm UTC](https://forum.inductiveautomation.com/t/change-every-view-on-tag-change-fire-alarming/95382/10 "2024-08-30T21:40:20Z")

</div>

Show what you have tried and we will be glad to advise of errors or places where perhaps there is a better practice to achieve your goal. Without knowing what you have tried it is hard to suggest what you might need to 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:** [August 30, 2024, 9:55pm UTC](https://forum.inductiveautomation.com/t/change-every-view-on-tag-change-fire-alarming/95382/11 "2024-08-30T21:55:18Z")

</div>

Something like this (in the property change event):

```python
def valueChanged(self, previousValue, currentValue, origin, missedEvents):
	if currentValue.value:
		for page in self.session.pages:
			system.perspective.openPopup(page.id+"_Emergency", "Path/To/Emergency/View",
				showCloseIcon=False, draggable=False, modal=True, pageId=page.id)

```

The view that you launch will need a "close" button that is enabled when the tag goes false. The popup is given a predictable view ID composed from the page ID so that you can precisely target the close popup operation.

It would probably be good to update the Perspective Session Properties documentation to describe `session.page` and `session.pages`.

---

<div class="post-metadata">

**Author:** ![Jeff\_Muldoon](https://avatars.discourse-cdn.com/v4/letter/j/ce73a5/32.png) [@Jeff\_Muldoon](https://forum.inductiveautomation.com/u/Jeff_Muldoon)\
**Post date:** [August 30, 2024, 10:40pm UTC](https://forum.inductiveautomation.com/t/change-every-view-on-tag-change-fire-alarming/95382/12 "2024-08-30T22:40:03Z")

</div>

Tbh, I'm about ready to give up. I've spent most of the time just googling stuff trying to figure it out as my python/jython is introductory at best. I'm able to get by with basic stuff so far and transforms for most of what I've been doing, but I really need to learn this stuff/ do the Gold Course, cuz python is nowhere in my background.
