# Associated Data in tags AlarmActive event

**URL:** <https://forum.inductiveautomation.com/t/associated-data-in-tags-alarmactive-event/14602>\
**Category:** Ignition\
**Created:** [June 22, 2017, 7:45am UTC](https://forum.inductiveautomation.com/t/associated-data-in-tags-alarmactive-event/14602 "2017-06-22T07:45:53Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![ktran](https://avatars.discourse-cdn.com/v4/letter/k/ecae2f/32.png) [@ktran](https://forum.inductiveautomation.com/u/ktran)\
**Post date:** [June 22, 2017, 9:18pm UTC](https://forum.inductiveautomation.com/t/associated-data-in-tags-alarmactive-event/14602/2 "2017-06-22T21:18:46Z")

</div>

Hi zxcslo, there appears to be a bug with the alarmEvent.get() function in the context of Tag Event scripts. However there is a workaround. Please copy the unicodeDataToDict() and getActiveData() function into your script and call getActiveData() with alarmEvent as the function parameter. This will return a dictionary object in which you can access your associated data with the [] operator. See below for an example.

```python
	# Converts the unicode string returned by activeData.toString() into a python dictionary
	def unicodeDataToDict(unicode):
		import ast
		
		# Makes sure the unicode conforms to dictonary format by doing various string replacements
		unicode = unicode.replace("{", "{'")
		unicode = unicode.replace("}", "'}")
		unicode = unicode.replace('=', "':'")
		unicode = unicode.replace("," , "','")
		unicode = unicode.replace("' " , "'")
		
		# Converts the unicode string to a dictionary object
		return ast.literal_eval(unicode)
	
	# Returns various alarm properties including associated data as a python dictionary
	def getActiveData(alarmEvent):
		activeData = alarmEvent.getActiveData()
		
		# We can't explicilty access the data inside activeData so perform a workaround here.
		# Calling the print() function on an activeData object will return a unicode string containing
		# various alarm property names mapped to its corresponding values.
		# E.g. {name=myAlarm}
		# We will then format this unicode string so that it conforms with the syntax of a python dictionary
		# and then convert into a dictionary object 
		activeDataDict = unicodeDataToDict(activeData.toString())
		return activeDataDict
	
	
			
	activeDataDict = getActiveData(alarmEvent)
	# You can access alarm properties by doing: activeDataDict['NAME_OF_ASSOCIATED_DATA']
	# Note that all values in the dictionary are in string format so it may be necessary 
	# to do some casting.
	deviceName = activeDataDict['deviceName']
	hostname = activeDataDict['hostname']
	

```

---

_[View the full topic](https://forum.inductiveautomation.com/t/associated-data-in-tags-alarmactive-event/14602)._
