Gateway Tag Change Script Can't Read Relative Tag Path Value?

I'm creating a gateway tag change script that needs to read other tag values in the same folder as the tag that the script is pointed to. I noticed that using a relative tag path doesn't work in the gateway tag change script, but it does in a tag value changed script.

Tag Value Changed Script:

relativePathTagID = system.tag.readBlocking("[.]Tag ID")[0].value
absolutePathTagID = system.tag.readBlocking("[default]Test Tags/Tag ID")[0].value
	
logger = system.util.getLogger("TagChangeScript")
logger.info("Relative Tag ID value: " + str(relativePathTagID))
logger.info("Absolute Tag ID value: "+ str(absolutePathTagID))

Gateway Tag Change Script (tag path pointed to same tag using the tag value changed script):

relativePathTagID = system.tag.readBlocking("[.]Tag ID")[0].value
absolutePathTagID = system.tag.readBlocking("[default]Test Tags/Tag ID")[0].value

logger = system.util.getLogger("GatewayTagChangeScript")
logger.info("Relative Tag ID value: " + str(relativePathTagID))
logger.info("Absolute Tag ID value: "+ str(absolutePathTagID))

Logs:

Do gateway tag change scripts use a different way to reference relative tag paths? Or am I forced to construct the absolute path to read other tag values?

You must construct a fully qualified path in the script.

Do not fear, as the event gives you the tools to work with.

event.getTagPath()

Will return a Tag Path object.

This means that you can do something like this:

logger = system.util.getLogger("GatewayTagChangeScript")
tagID = system.tag.readBlocking([event.getTagPath().parentPath.getChildPath("Tag ID")])[0].value
logger.info("Tag ID value: " + str(tagID))
2 Likes

Can also be written as event.tagPath fwiw.

1 Like

I wasn't sure because the documentation is contradictory here.

There is both a getTagPath() and tagPath listed? :man_shrugging:

1 Like

Funny enough found this post from you - Iterate Through Components In Container (Vision) - #10 by lrose

Though looking at the documentation I see what you mean, that is confusing.

They are the same thing. Whoever wrote that part of the docs didn't understand what jython does with NetBeans-compliant getter/setter methods.