UDT tag Scripting

You won't be able to use relative tag paths directly because your call to system.tag.readBlocking() or system.tag.writeBlocking() requires the full path to the tag. You'll have to build the path to the appropriate tag using string manipulation in python. To the python script "[~]" and "[.]" are plain old strings, just like any other and have no meaning in the context of a path. So, you'll have to manipulate the path manually using the path string parameter in the change script.

image

def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
	
	#check that value changed - not quality
	if (previousValue <> currentValue):
	
		#build the path to PrevValue from path to Value (i.e. substitute "PrevValue" for "Value")
		#<string>[0:-x] gets the entire string, minus the last x characters
		prevTagPath = tagPath[0:-5] + "PrevValue"
	
		#write the previous value to the tag
		system.tag.writeAsync([prevTagPath], [previousValue])

From your screenshots, it looks like your previous value tag is outside of the UDT. Just add it to the UDT like I have above. Makes things much easier. Adding a tag to the UDT should to affect any of the existing elements.