Recently I ran into a situation where I found that it would be required to have a tags provider be stored in a UDT as meta data. At first I thought to use the {PathToParentFolder}
built in parameter however this did not work as it does not include the tags provider.
I ended up discovering that relative tag paths not only work in UDT Expressions but also UDT Scripts. Knowing this I was able to make the following Tag Event Script that writes the Tag Provider to the (string) UDT Member Tag (Memory - String) that it is bound to:
if initialChange:
# retrieve configuration for relative tag provider
config = system.tag.getConfiguration('[~]', False)
# retrieve the actual path and set the tag value
system.tag.writeAsync([tagPath], [config[0]['path']])
The system.tag.getConfiguration()
built in function (without the recursive boolean flag set) returns a list of python dictionaries containing tag configuration information for the provided path.
In this case since we are providing only a tag provider ([~]
is relative to the Tag provider of the Tag that is being bound) this function will always return a list containing one dictionary containing 2 keys. One of these keys is path
which holds full path for the tag provider.