# IA Scripting to extract alarm details

**URL:** <https://forum.inductiveautomation.com/t/ia-scripting-to-extract-alarm-details/7349>\
**Category:** Ignition\
**Created:** [October 1, 2013, 11:03am UTC](https://forum.inductiveautomation.com/t/ia-scripting-to-extract-alarm-details/7349 "2013-10-01T11:03:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Powerplan](https://avatars.discourse-cdn.com/v4/letter/p/aca169/32.png) [@Powerplan](https://forum.inductiveautomation.com/u/Powerplan)\
**Post date:** [October 1, 2013, 11:03am UTC](https://forum.inductiveautomation.com/t/ia-scripting-to-extract-alarm-details/7349/1 "2013-10-01T11:03:42Z")

</div>

Hi all

Version 7.6.3

We are currently attempting to create a table within our system which gives information and current settings of all configured alarms within the gateway, using features within the IA Labs scripting module (1.6.4) to get the attributes of the tags and using the current alarm severity to filter out non-alarm tags within the project. Here is the code we are attempting to use:

[code]system.db.runUpdateQuery(“Delete from alarms”)  
tags = system.tag.browseTags(parentPath="", recursive=1)  
for tag in tags:  
tagDefs = system.tag.getAttribute(tag.fullPath,“AlertCurrentSeverity”)

```
if (tagDefs >= 0):	
	xID = system.db.beginTransaction()
	path = tag.fullPath
	name = system.tag.getAttribute(tag.fullPath,"Name")
	message = system.tag.getAttribute(tag.fullPath,"AlertMessage")
	displayP = system.tag.getAttribute(tag.fullPath,"AlertDisplayPath")
	execEn = system.tag.getAttribute(tag.fullPath,"AlertExecEnabled")
	alertMode = system.tag.getAttribute(tag.fullPath,"AlertMode")
	ackMode = system.tag.getAttribute(tag.fullPath,"AlertAckMode")
	print path
	system.db.runUpdateQuery("INSERT INTO alarms (path, severity, name, Alert_Message, Alert_DisplayPath, Alert_ExecEnabled, Alert_Mode, Alert_AckMode) VALUES ('%s','%s','%s','%s','%s',%s, %i, %i )" % (path, tagDefs,name, message, displayP, execEn, alertMode, ackMode))		
	system.db.commitTransaction(TxID)
	system.db.closeTransaction(TxID)

```

system.nav.closeWindow(‘Script\_running’)[/code]

With this code we do retrieve some of the information from the tags (path,severity,name,AlertExecEnabled,AlertMode,AlertAckMode) but no results for the display path or the alert message are inserted into the database, I have tested running the .getAttribute on single tags with alarms using the script playground and am unable to get the information this way either,

We have notice that some configured alarms show a NULL or -1 property (such as “AlertCurrentSeverity”) when the alarm is not active but have the correct value when active. This has prevented us from finding all configured alarms, is there a different property we could use?

we would also like to extract the current setpoint and current notification pipeline.

We are obliged to provide a current list of configured alarms to our customer.

many thanks

---

<div class="post-metadata">

**Author:** ![Robert.McKenzie](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/robert.mckenzie/32/4134_2.png) [@Robert.McKenzie](https://forum.inductiveautomation.com/u/Robert.McKenzie)\
**Post date:** [December 24, 2013, 7:27pm UTC](https://forum.inductiveautomation.com/t/ia-scripting-to-extract-alarm-details/7349/2 "2013-12-24T19:27:03Z")

</div>

I would try using the system.tag.getAlarmStates() function from the IALabs Scripting Module. Try this to get you going:`tags = system.tag.browseTags(parentPath="", recursive=1)
for tag in tags:
	try:
		tagDefs = system.tag.getAlarmStates(tag.fullPath)
		if len(tagDefs) > 0:
			print ""
			for tagDef in tagDefs:
				print "Alarm Name:", tagDef.alarm
				print "Props:"
				for prop in tagDef.getAlarmProperties():
					print prop.property, prop.type, prop.value
	except:
		pass`

---

<div class="post-metadata">

**Author:** ![MGambrell](https://avatars.discourse-cdn.com/v4/letter/m/e19adc/32.png) [@MGambrell](https://forum.inductiveautomation.com/u/MGambrell)\
**Post date:** [January 3, 2014, 1:30pm UTC](https://forum.inductiveautomation.com/t/ia-scripting-to-extract-alarm-details/7349/3 "2014-01-03T13:30:12Z")

</div>

Thank you for the reply, sadly however this solution doesn’t solve the issue, when this script runs the output is [quote]displayPath Expression {[.]Board}+" “+{[.]Name}+” Tripped"  
[/quote] whereas we require the output to be [quote]displayPath Expression HV1.1 Board 3 Tripped [/quote]This is the same for the Priority and the Enabled Tag, so what is required is that the values for the tags to be printed instead of the tag name.

---

<div class="post-metadata">

**Author:** ![Robert.McKenzie](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/robert.mckenzie/32/4134_2.png) [@Robert.McKenzie](https://forum.inductiveautomation.com/u/Robert.McKenzie)\
**Post date:** [January 15, 2014, 12:48am UTC](https://forum.inductiveautomation.com/t/ia-scripting-to-extract-alarm-details/7349/4 "2014-01-15T00:48:27Z")

</div>

Unfortunately there is no way to fill in that information at the moment. I will add a request to make all UDT properties evaluate for the getAlarmStates() function, but it may not be something we can implement any time soon.

---

<div class="post-metadata">

**Author:** ![Jatin\_Kumar\_Singh](https://avatars.discourse-cdn.com/v4/letter/j/87869e/32.png) [@Jatin\_Kumar\_Singh](https://forum.inductiveautomation.com/u/Jatin_Kumar_Singh)\
**Post date:** [September 23, 2022, 4:29pm UTC](https://forum.inductiveautomation.com/t/ia-scripting-to-extract-alarm-details/7349/5 "2022-09-23T16:29:57Z")

</div>

Hi, I am doing a project in 7.9. I am looking to see the output of expression. But all I get is the expression tied to the alarm property. Was the request to make all UDT properties evaluate for the getAlarmStates() function completed? If not, is there any alternate way to get the output of those expressions.

I am trying to build an Alarms Screen and they want all the required info like priority, display path, etc. And all these properties are tied to some other stuff in the UDT.
