Scripted editing of UDT definitions - modifying alarm names

I’m trying to script the bulk editing of alarm names within a UDT definition, e.g. the highlighted property. Basically I want to bulk rename the alarm name to the alarm tag name. I really wish that this was accessible as a property to show in the alarm headers…
image

I’m struggling… does anyone have a script already to do this or something similar?

I have this:
Very simple UDT definition for testing with:

udtTagFolder = '_types_/_Testing'
udtName = 'Simple'
tagsc = system.tag.browseConfiguration(udtTagFolder,1)
for tagc in tagsc:
	if tagc.getName() == udtName:
		tags = tagc.getSubTags()
		# gets the first "tag" i.e. the folder "Alarms",
		# then gets the tags within the folder (array of 1 tag),
		# the the 1st tag within the folder ('Faulted'), and its alarm configuration
		alarms = tags[0].getSubTags()[0].getAlarms()
		print alarms, type(alarms)
		for alarm in alarms:
			print alarm, type(alarm)

The result of this is:

[Faulted] <type 'com.inductiveautomation.ignition.common.tags.config.AlarmDefinitions'>
Faulted <type 'com.inductiveautomation.ignition.common.alarming.config.BasicAlarmDefinition'>

I’m not quite sure how to edit alarm's name property and then write it back to the tag configuration.

Hi Nick,

Did you get anywhere with this?
I'm currently looking at trying to build a Vision popup which can display (and eventually hopefully re-configure using scripting) the alarm configuration for any UDT tag instance.

Struggling with the fact that the new system.tag.getConfiguration only returns changed properties, not ALL which is very frustrating.

Be aware that editing alarms in UDTs via scripting will override the entire alarm definition, which kind of defeats the purpose of a UDT.

There are some examples here,
https://docs.inductiveautomation.com/display/DOC81/system.tag.configure

There's a script i've posted before that gets all alarm config fields, I'll have to find it

Edit: Found it

I think i've managed to avoid this now with my latest iteration of configure scripts. You need to just ensure you only send back the json values required for the change, and not the whole configuration object.

Thanks will have a look through all that.

Best of luck, unless they changed it in the last month, it doesn't work that way for alarms. You can do what you described for tags, just not alarms.

1 Like