Problem with system.tag.getConfiguration when getting parameters of UDT instance

We’re currently running on version 8.1.7 and are using system.tag.getConfiguration to iterate through UDT instances to get certain parameter values.

The code looks like this:

nodes=system.tag.getConfiguration(path,False)

for item in nodes:
	for key,value in item.iteritems():
		print key,value
		if key=='parameters':
			parameterValueDict=value
			for key,value in parameterValueDict.iteritems():
				print key,value

We have multiple UDT types and dozens of instances. The above code will return data for the parameters that looks like this:

parameters {u'DeviceIP': {datatype=String, value=10.27.16.105}, u'DeviceName': {datatype=String, value=[WS15127_10]}}

However, we have one UDT that returns a different format, which looks like this:

parameters {u'DeviceIP': u'10.27.16.180', u'DeviceName': u'[WS15427_10]'}

This UDT was originally copied from another UDT and then modified. I deleted the instance and definition then created a new UDT from scratch. The result was the same.

From a code standpoint, I added a try/except to handle both versions of data:

nodes=system.tag.getConfiguration(path,False)

for item in nodes:
	for key,value in item.iteritems():
		print key,value
		if key=='parameters':
			parameterValueDict=value
			for key,value in parameterValueDict.iteritems():
				print key,value
				if key=='DeviceName':
					parameterValue=value
					try:
						myDeviceName=parameterValue.getValue()
					except:
						myDeviceName=parameterValue

This works, but thought I would post to see if anyone has any thoughts on what I may be doing wrong with respect to the UDT setup (or anything else) that would cause this difference. Any input is appreciated.

Thanks in advance.

1 Like

Hi SteveW,

Your script works when I create a UDT instance, maybe try to create the UDT definition from scratch to see if that fixes that. I don't think you're doing anything wrong necessarily.

parameters {u'DeviceIP': u'10.27.16.180', u'DeviceName': u'[WS15427_10]'}

The "u" character indicates a unicode string (which is a way for a string to represent more characters than a regular ASCII string can).

However, if you'd like us to further investigate this, please open up a support ticket with us!
https://www.inductiveautomation.com/support/home/