# Open dock on active alarm

**URL:** <https://forum.inductiveautomation.com/t/open-dock-on-active-alarm/94715>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [August 15, 2024, 7:05pm UTC](https://forum.inductiveautomation.com/t/open-dock-on-active-alarm/94715 "2024-08-15T19:05:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![GChase](https://avatars.discourse-cdn.com/v4/letter/g/b3f665/32.png) [@GChase](https://forum.inductiveautomation.com/u/GChase)\
**Post date:** [August 15, 2024, 7:05pm UTC](https://forum.inductiveautomation.com/t/open-dock-on-active-alarm/94715/1 "2024-08-15T19:05:13Z")

</div>

I have a gateway script that counts active alarms, if the alarm count is greater than 0 , I would like to open a dock for all sessions on any page.  
What is best way to go about this?

---

<div class="post-metadata">

**Author:** ![Dharani\_T](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@Dharani\_T](https://forum.inductiveautomation.com/u/Dharani_T)\
**Post date:** [August 17, 2024, 8:32am UTC](https://forum.inductiveautomation.com/t/open-dock-on-active-alarm/94715/2 "2024-08-17T08:32:43Z")

</div>

Whenever the condition meets, write some value to tag. bind the tag to a session variable.  
On change of this session variable, open a popup.

---

<div class="post-metadata">

**Author:** ![GChase](https://avatars.discourse-cdn.com/v4/letter/g/b3f665/32.png) [@GChase](https://forum.inductiveautomation.com/u/GChase)\
**Post date:** [August 17, 2024, 3:03pm UTC](https://forum.inductiveautomation.com/t/open-dock-on-active-alarm/94715/3 "2024-08-17T15:03:17Z")

</div>

This thread lead me to the answer as I finally realized it is no different from a common alarm pop-up use case :

> [@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/4):
>
> @mcgheeiv has supplied one route, but the problem is that session properties have no insight into the page in use, which is required when opening a Popup. Your logs would supply an exception or error along the lines of “No perspective page attached to thread.” There are some important things to consider when planning this: Each browser session could have multiple pages open, so which page gets the Popup? The first page found for a session, or all pages? What conditions would warrant closing the…

@cmallonee supplied a function that got the community started.  
@wakatipu discovered that (On Ignition Edge designer 8.1.22) if the designer is running the code would exit the for loop before getting to the true sessions so the designer was excluded.

```python
 if session.userAgent != "<designer>":

```

This is the script after reworking it for docked view system functions:

```python
def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
	dockId = "alarm" #dock ID
	logger = system.util.getLogger("dock") #optional logging 
	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>": #exclude designer
				if currentValue and currentValue.value:
					system.perspective.openDock(dockId, sessionId=session.id, pageId=pageId)
				else:
					system.perspective.closeDock(dockId, sessionId=session.id, pageId=pageId)

```

(I also ditched my gateway script to evaluate active alarms for a Boolean reference tag on [System]Gateway/Alarming/Active and Unacked as I have only one project on this Gateway)
