Relative tag path referencing

This is a short tutorial on relative tag path referencing for multiple levels. The Ignition help has a page labeled Tag Paths but it only shows relative referencing for the current folder, or all the way back to the tag provider at its root. Maybe this will help those who want to reference tags that are one or more levels above the current level.

For this tutorial, I have built three levels, named Parent, Child, and Grandchild. In the Parent folder is a simple string type memory tag named ParentTag. Its text is ‘This is the ParentTag text’. In the Child folder is another simple string type memory tag named ChildTag whose text is ‘This is the ChildTag text’. Here is a snip from the browser showing that much.

[attachment=1]Capture.JPG[/attachment]

In the Grandchild folder are two simple string type expression tags named ChildTagText and ParentTagText. These two tags will reference the memory tags in the folders above them using relative tag path expressions. The expression for ChildTagText, which references ChildTag, a level up from it, is shown below.

{[.]../ChildTag}

Notice that the expression is within curly braces and begins with [.] which is a reference to the current folder. Next is … which means move up a level. And finally is a / and the tag name in the Child folder.

The expression for ParentTagText, which references ParentTag, two levels up is shown below.

{[.]../../ParentTag}

Again, within the curly braces we start with [.] to reference the current folder, then …/… which means move up two levels, then a / and the tag name in the Parent folder. To show the results, below is a snip from the fully expanded area in the SQL tags browser. Notice that the text in ChildTagText is the same as the text in ChildTag, and the text in ParentTagText is the same as the text in ParentTag.

[attachment=0]Capture.JPG[/attachment]

I hope this helps.

4 Likes

Ok, I added a little something extra. This will show how to go up the tree and down another branch to reference something in that branch.

I added another sub-folder under the parent named Child2, and in that sub-folder I added another simple string type memory tag named Child2Tag. The text for that tag is ‘This is the Child2Tag text’. This is how the tree looks now.

[attachment=1]Capture.JPG[/attachment]

Next , in the Grandchild folder, I added another simple string type expression tag named Child2TagText. It will reference the Child2Tag in the Child2 sub-folder of the Parent folder by going back up the tree from Grandchild to Child, up from Child to Parent, down to Child2, and reference its Child2Tag. Here is how the tree looks after that.

[attachment=0]Capture.JPG[/attachment]

The expression used in Child2TagText to do this is shown below.

{[.]../../Child2/Child2Tag}

As you can see, the text of Child2TagText is the same as the text of Child2Tag.

2 Likes

I want to say THANK YOU!! for taking the time to post this. I was having syntax issues while trying to get tag path referencing down. Appreciate.

1 Like

9 years later I want to also so thank you. It’s was hard to find this exact fix to my issue but thankfully your post was here. I have a UDT nested inside another UDT. I have a tag Global_Sim which is a boolean memory tag to simulate all tags that are part of the parent and child UDT. I have a child tag called Inp_Sim that I wanted to get to turn on when I turn on the Global_Sim point. I was doing it wrong inside my child tag (Inp_Sim) expression. Initially I was using {[.]…/…/…/UDT_Folder/Parent_UDT_Definition/Global_Sim}

Simply needed to wipe out the UDT folders and naming and shorten to two levels up and just grab the point.
{[.]…/…/Global_Sim}
Worked! Thanks again