Perspective Alarm Query

Hoping someone can point me in the right direction.

I have tags that are sorted in folders as follows:

  • Machine A
  • Machine B
  • Machine C

In my perspective application, I have a MenuTree component with menu’s as per above strucure. i.e.,

  • Machine A
  • Machine B
  • Machine C

My question is as follows:
a. How would I run a query on each menu item to change the text to red if there is any alarm in the tag folder?
b. How would I run a query on each menu item to blink the text if there is any unack alarm in the tag folder?

Is there a better way to achieve the above?

Any help is appreciated, thanks.

Edited to say I wrote all the below when there is a easier way. The menu A text color can have a expression binding…

if ({[default]MachineA/MATagAlarm}=1, "#CC4828", "#00FF00")

I had a go at this one for changing text color…

In the folder for Machine ‘A’ I created a expression tag with the expression below. Extend it if you have more tags. I made the datatype INT so it gives a 0 or 1 if any of the tags are true.

{[.]MAtagA} || {[.]MAtagB} || {[.]MAtagC} = true

You might want to drill down into the is alarm active value depending on how you have things set up.

Then on the Machine A menu I created 2 custom properties. The value binds to the expression tag above so goes 1 or 0 depending on state.


On the value property I added a change script.

	value = self.custom.value
	if  value == 1:
		self.custom.color = '#CC4828'
		value == 0
		self.custom.color = '#F93E10'

You can change the hex value to what color you want.

This then writes the hex code to the color custom property.

Then on the textstyle color property I bound that to the color custom property.

In the change script you could directly address the text style color but I like to keep things separate so i can see what’s going on and test. Personal preference I guess. But it would be something like…

	value = self.custom.value
	if  value == 1:
		self.props.textStyle.color = '#CC4828'
		value == 0
		self.props.textStyle.color = '#00FF00'

I hope that helps, or at least gets you started.

This is the end result that will need tailored to fit your application…


No Alarm;

Thank you so much @craigb for the detailed response. Your solution makes absolute sense when the tags are known in each folder. How can I detect an alarm in a folder if the tags are variable. i.e. in your expression you explicitly mention tags a to c. What if I add a tag d into the folder, I would have to update the expression, there could potentially be 100’s of tags in a folder.

Do you know of a script/expression to detect an alarm in a folder, without having to hardcode each tag?

Many thanks

Be very careful calling system.alarm.queryStatus as it will cause performance issues the more you call it and it will not scale, but you can use this function to query active alarms. I suggest calling this once periodically from a gateway scope such as from a tag using runScript and store the result into a module variable. You can then process the module variable to summarise the alarms for any folder level. Keep in mind you’ll need to do this all within the same scope eg all within tags

I think many have a similar requirement and hence I have requested some form of aggregation.

Tag Alarm Aggregation | Voters | Inductive Automation (

I see it is under review. Maybe a few more votes can speed matters along