I am updating tag alarm properties in code. I was using the following code to update tag alarms. Everything was working great!
#Get property name to Change
PropertyName = "NewProperty"
#Get property Value to Change
PropertyValue = event.source.parent.getComponent("txtCustomProperty").text
#Create Alarm configuration
alarmConfig = {AlarmName:[[PropertyName,"Value",PropertyValue]]}
editTagPath = [tagPath]
#Edit alarm configuration
system.tag.editAlarmConfig(editTagPath,alarmConfig)
But there is a problem when I run this code with DataType Instance Tags. [color=#FF0040]This code will create/edit the “NewProperty” name and value, but it wipes out the existing alarm names and values. [/color]
So I need to make a work-around for this in which it doesn’t wipe out the other properties. I thought, “I should make a dictionary of the existing alarm properties and values, add my new customer property and value to it, and send that into the ‘editAlarmConfig’ function.”
But I have hit a bump: I made a dictionary of Alarm Properties and the Alarm Values. I can’t seem to figure out how to get this dictionary into the editAlarmConfig Function. I feel like I am fitting a square peg into a round hole.
The PropertyDictionary consists of PropertyName = Property Value keyed pairs.
alarmConfig = {AlarmName:PropertyDictionary}
editTagPath = [tagPath]
#Edit alarm configuration
system.tag.editAlarmConfig(editTagPath,alarmConfig)