# How to find active alarm on page

**URL:** <https://forum.inductiveautomation.com/t/how-to-find-active-alarm-on-page/35347>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [June 5, 2020, 8:17am UTC](https://forum.inductiveautomation.com/t/how-to-find-active-alarm-on-page/35347 "2020-06-05T08:17:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![doshinikhil](https://avatars.discourse-cdn.com/v4/letter/d/9de053/32.png) [@doshinikhil](https://forum.inductiveautomation.com/u/doshinikhil)\
**Post date:** [June 5, 2020, 8:17am UTC](https://forum.inductiveautomation.com/t/how-to-find-active-alarm-on-page/35347/1 "2020-06-05T08:17:22Z")

</div>

I have templates for Motor,Valves,A\_In etc in my project. I have placed objects on different screens. Now suppose I have a motor fault in one particular motor which is placed in Screen A. Now I want to show the status of active alarm on the navigation bar. So I need to change the color of navigation button for Screen A if any alarm is active on that page.

Thanks in advance.

---

<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:** [June 5, 2020, 8:38am UTC](https://forum.inductiveautomation.com/t/how-to-find-active-alarm-on-page/35347/2 "2020-06-05T08:38:47Z")

</div>

You can’t do this dynamically if that’s what you’re asking. You will need produce a list of alarm filters to use for each screen yourself, whether by hand, or your tags for each page might be located in their own folders (could work for pages that belong to an area with 1 page per area, but you’ll need to consider long term if they will remain 1 page), or it could be semi-automatically via a script that pulls out the device paths. You could technically copy the page’s XML and pull out tag paths from that…

To pull out the tag paths from the page XML, assuming they all have “/” in them, you could use this regex:  
`(?<=>)[\w\d]+\/[/\w\d]+(?=<)`

> **[RegExr: Learn, Build, & Test RegEx](https://regexr.com/565au)**
>
> RegExr is an online tool to learn, build, & test Regular Expressions (RegEx / RegExp).

```auto
E.g. "<str>Pigging/Pig Launchers/Red Line 1</str>"
(?<=>) # search for a '>' before the search result without including it in the result (positive lookbehind)
[\w\d]+ # look for 1 or more of any character, number, or space character
\/ # escape special character '/' and search for 1 '/'
[/\w\d]+ # look for 1 or more of a /, and character, number, or space character
(?=<) # search for a '<' after the search result without including it in the result (positive lookahead)

```

You can use the below script in the Script Console which uses the regex above to pull out the tags (again, assuming there is at least one “/” in the tagPath) from the XML copied to the clipboard (Shift+right click on the window and select _Copy XML to Clipboard_):  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/e/e62232e8e439af95e6a3d39d09b0a739cb4bef40.png)

```auto
def readClipboard():
	from java.awt.datatransfer import StringSelection
	from java.awt.datatransfer import Clipboard
	from java.awt import Toolkit 
	
	toolkit = Toolkit.getDefaultToolkit()
	clipboard = toolkit.getSystemClipboard()
	from java.awt.datatransfer import DataFlavor
	contents = clipboard.getContents(None)
	return contents.getTransferData(DataFlavor.stringFlavor)

XML = readClipboard()

import re
pattern = '(?<=>)[\w\d]+[/][/\w\d]+(?=<)'

tags = re.findall(pattern, XML)
for tag in tags: print tag

```

---

<div class="post-metadata">

**Author:** ![doshinikhil](https://avatars.discourse-cdn.com/v4/letter/d/9de053/32.png) [@doshinikhil](https://forum.inductiveautomation.com/u/doshinikhil)\
**Post date:** [June 5, 2020, 10:33am UTC](https://forum.inductiveautomation.com/t/how-to-find-active-alarm-on-page/35347/3 "2020-06-05T10:33:19Z")

</div>

Thank you very much…I will try this solution

---

<div class="post-metadata">

**Author:** ![Sanderd17](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sanderd17/32/8735_2.png) [@Sanderd17](https://forum.inductiveautomation.com/u/Sanderd17)\
**Post date:** [June 5, 2020, 11:13am UTC](https://forum.inductiveautomation.com/t/how-to-find-active-alarm-on-page/35347/4 "2020-06-05T11:13:18Z")

</div>

I find the use of lookahead an lookbehind interesting, however I have never needed that syntax (so I also didn’t recognise it at first).

I normally define what should be captured, like this: `>([\w\d]+/[/\w\d]+)</`  
To me, it’s more readable what do you think?

PS. the `/` also isn’t a special character in regexes. It’s only special in JS where it’s used as regex delimitor (instead of quotes).

---

<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:** [June 5, 2020, 1:27pm UTC](https://forum.inductiveautomation.com/t/how-to-find-active-alarm-on-page/35347/5 "2020-06-05T13:27:24Z")

</div>

> [@Sanderd17](#):
>
> PS. the `/` also isn’t a special character in regexes. It’s only special in JS where it’s used as regex delimitor (instead of quotes).

Use of '/' as a regex delimiter long precedes javascript. I used it a few times this week with `sed`.
