# Attempting dynamic reference tags using expressions; baffled by behavior

**URL:** <https://forum.inductiveautomation.com/t/attempting-dynamic-reference-tags-using-expressions-baffled-by-behavior/74403>\
**Category:** Ignition\
**Tags:** ignition81, vision\
**Created:** [May 31, 2023, 11:33pm UTC](https://forum.inductiveautomation.com/t/attempting-dynamic-reference-tags-using-expressions-baffled-by-behavior/74403 "2023-05-31T23:33:10Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![sherman](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@sherman](https://forum.inductiveautomation.com/u/sherman)\
**Post date:** [May 31, 2023, 11:33pm UTC](https://forum.inductiveautomation.com/t/attempting-dynamic-reference-tags-using-expressions-baffled-by-behavior/74403/1 "2023-05-31T23:33:10Z")

</div>

I am trying to do somewhat dynamic tag linking without UDTs, and am having a bit of a struggle with the expression language.

First question: is there a good way to reliably prototype expressions? I want to try some out and see what their resulting value is.

Main question:

I have a tag provider called `[PROJ]` that has all of the imported variables autonamed from my PLC documentation. It is a flat folder that serves as a starting point for my HMI. I then have a tag provider called `[HMI]` that is to be organized more like the HMI itself. Both of these tag providers have identically named subfolders representing the system they are concerned with.

So I have `[PROJ]TB0` which contains all of my named variables, and `[HMI]TB0` which will have subfolders representing logical groupings.

Concrete example: I am trying to build a reference sending the boolean `[PROJ]TB0/pal_valve_0` to `[HMI]TB0/plc/pal/valve_0/state`, and I now realize that the variables like `{InstanceName}` or `{ParentInstanceName}` are all UDT-specific variables. So I want to do this with more generic path parsing. I know `[~]` represents the current tag provider, and `[.]` represents the parent folder of a given tag, with something like `[.]..` representing the folder above that.

So I am trying to understand how to do this by using a Standard Tag -\> Expression -\> String and then trying to extract the paths to read them (since I can't figure out a better way to test expressions; dereferencing these would be my next step) and it is really confusing me: the expression `"[PROJ]" + {[.]../../..} + "/" + {[.]..} + "_" + {[.]}` yields a value of `[PROJ]2/3_3`. Even just `{[.]}` yields `3` instead of `valve_0` like I would have expected.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/7/c79d512df856257ee7f9b8553ac02f174449e128.png)

I am just terribly confused and hope someone can show me what I am doing wrong! Ill keep at it in the meantime.

Also -- how can I access a property of a tag that is identified by relative location? `{[.].Name}` yields `valve_0` which is good news, but `{[.]...Name}` doesn't work (I didn't expect it to, really). `{[.]../.Name` returns `null`. If I can go for the Name field of the directories above, I can construct a tag path that way.

---

<div class="post-metadata">

**Author:** ![sherman](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@sherman](https://forum.inductiveautomation.com/u/sherman)\
**Post date:** [June 1, 2023, 12:05am UTC](https://forum.inductiveautomation.com/t/attempting-dynamic-reference-tags-using-expressions-baffled-by-behavior/74403/2 "2023-06-01T00:05:08Z")

</div>

`{[.]}` yields `3` (valve\_0)  
`{[.]..}` yields `3` (pal)  
`{[.]../..}` yields `2` (PLC)  
`{[.]../../..}` yields `2` (TB0)  
`{[.]../../../..}` yields `2` ([HMI]) -- tag provider level  
`{[.]../../../../..}` yields `BrowseValue [value=null, info=null, configVersion=14]`

All additional /.. addendums remain with the final response forever, which makes sense at least.

At first I thought maybe the 3 was the depth but I was quickly disabused of that. I have no idea what that number represents -- it should be a folder but what _is_ a folder?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [June 1, 2023, 12:38am UTC](https://forum.inductiveautomation.com/t/attempting-dynamic-reference-tags-using-expressions-baffled-by-behavior/74403/3 "2023-06-01T00:38:54Z")

</div>

You are going to be endlessly frustrated trying to convert relative stuff to absolute. Also, these relative expressions are only going to be available within expression tags, whether in UDTs or not. Almost none of this will work in UI bindings. But there, you (will) have tagpath parameters to work with.

Please note that there is nothing wrong with UDTs in the tag hierarchy, and their internal tools and parameters are very helpful indeed for many tasks. At no point in yesterday's long rants did I suggest abandoning UDTs entirely--just to not use UDT **UI properties**.

---

<div class="post-metadata">

**Author:** ![sherman](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@sherman](https://forum.inductiveautomation.com/u/sherman)\
**Post date:** [June 1, 2023, 12:44am UTC](https://forum.inductiveautomation.com/t/attempting-dynamic-reference-tags-using-expressions-baffled-by-behavior/74403/4 "2023-06-01T00:44:09Z")

</div>

Ah I see -- a valuable distinction. I willl continue to use UDTs then, just never as a template property. Thank you for clarifying! The path of relative paths was making my eyes try to look straight at each other.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [June 1, 2023, 12:45am UTC](https://forum.inductiveautomation.com/t/attempting-dynamic-reference-tags-using-expressions-baffled-by-behavior/74403/5 "2023-06-01T00:45:26Z")

</div>

> [@sherman](#):
>
> Thank you for clarifying!

Might be worth rereading yesterday's topic from the top.

---

<div class="post-metadata">

**Author:** ![sherman](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@sherman](https://forum.inductiveautomation.com/u/sherman)\
**Post date:** [June 1, 2023, 1:05am UTC](https://forum.inductiveautomation.com/t/attempting-dynamic-reference-tags-using-expressions-baffled-by-behavior/74403/6 "2023-06-01T01:05:27Z")

</div>

Oh I have reread it all multiple times now. But now that I know you weren't telling me to abandon UDT's, I realize that when you say "UDT parameter" you mean the **template** parameter with **type** UDT, not the _parameters **of** the_ UDT. I had thought it was the actual underlying parameters of the UDT itself that were problematic as well as eventually coming to understand that I should not use a whole UDT as a Template Parameter ∴ I should use a non-UDT folder-based tag structure + tag path string template parameter to top level folder. Hence my foray into trying to generate relative linked tags.

I think this line knocked me a bit sideways:

> The string tag path _ **IS** _ the template parameter **instead of** a UDT parameter.

I _now_ read this as `the template parameter is string-type that is the tag's path, instead of being UDT-type that is the UDT itself`

UDT and \<UDT\> were being used interchangably occasionally and that I think also threw me off.

Anyway! I think 🤞 I have it now; is this correct:

- Template Parameter of type UDT: **ILLEGAL**
- Template Parameter of type String, referencing the _path_ of a UDT: **PREFERRED**

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [June 1, 2023, 1:12am UTC](https://forum.inductiveautomation.com/t/attempting-dynamic-reference-tags-using-expressions-baffled-by-behavior/74403/7 "2023-06-01T01:12:45Z")

</div>

> [@sherman](#):
>
> **ILLEGAL**

Well, it **is** _legal_. I would say **Unwise** , **Limiting** , **Frustrating** , **Slow** , and, at various times in the life of Ignition, **Buggy**.

I would add:

- UI Container Custom Property of type UDT: **Unwise**

- UI Component Custom Property of type UDT: **Unwise**

So too with Vision Client tags and Perspective session custom properties.

---

<div class="post-metadata">

**Author:** ![sherman](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@sherman](https://forum.inductiveautomation.com/u/sherman)\
**Post date:** [June 1, 2023, 1:16am UTC](https://forum.inductiveautomation.com/t/attempting-dynamic-reference-tags-using-expressions-baffled-by-behavior/74403/8 "2023-06-01T01:16:43Z")

</div>

Close enough to illegal for me! Possible but a no-no ~ illegal.

I haven't taken a foray into any other things in the meta-category of containers/templates/components, but is there anything that you _would_ recommend ( or at least not not recommend) having a property of type UDT?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [June 1, 2023, 1:18am UTC](https://forum.inductiveautomation.com/t/attempting-dynamic-reference-tags-using-expressions-baffled-by-behavior/74403/9 "2023-06-01T01:18:12Z")

</div>

Not a single one. It was/is a "feature" looking for an application that it won't crush. "We've invented these cool UDTs for tags! What else can we apply this to?" /not really putting words in IA developer mouths....

Hmmm. Maybe we should ask IA to deprecate them (the UDT UI properties, not UDTs themselves) for v8.3. SO MUCH grief could be avoided long-term.

---

<div class="post-metadata">

**Author:** ![sherman](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@sherman](https://forum.inductiveautomation.com/u/sherman)\
**Post date:** [June 1, 2023, 1:23am UTC](https://forum.inductiveautomation.com/t/attempting-dynamic-reference-tags-using-expressions-baffled-by-behavior/74403/10 "2023-06-01T01:23:10Z")

</div>

Copy that. Illegal everywhere.

Honestly the pain I already encountered trying to update them after they were in place makes this sort of a relief. Losing the drag and drop is a drag (😏) but I'll live.

I still have to figure out how to build my UDTs dynamically, but probably Ill eventually be constructing them via script anyway. Can't apparently nest {}'s in the expression language, so I can't do things like `{[PROJ]TB0/{InstanceName}}` 😠

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [June 1, 2023, 1:23am UTC](https://forum.inductiveautomation.com/t/attempting-dynamic-reference-tags-using-expressions-baffled-by-behavior/74403/11 "2023-06-01T01:23:43Z")

</div>

> [@sherman](#):
>
> my UDTs dynamically

JSON import/export.

---

<div class="post-metadata">

**Author:** ![sherman](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@sherman](https://forum.inductiveautomation.com/u/sherman)\
**Post date:** [June 1, 2023, 1:25am UTC](https://forum.inductiveautomation.com/t/attempting-dynamic-reference-tags-using-expressions-baffled-by-behavior/74403/12 "2023-06-01T01:25:09Z")

</div>

That works -- lets me build them in something a little more modern than jython 2.7.

---

<div class="post-metadata">

**Author:** ![sherman](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@sherman](https://forum.inductiveautomation.com/u/sherman)\
**Post date:** [June 1, 2023, 1:26am UTC](https://forum.inductiveautomation.com/t/attempting-dynamic-reference-tags-using-expressions-baffled-by-behavior/74403/13 "2023-06-01T01:26:06Z")

</div>

I was hoping I could get them a little more dynamic inside of the designer though, where they could grab the correct references simply by being named appropriately 🤷‍♂️

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [June 1, 2023, 1:33am UTC](https://forum.inductiveautomation.com/t/attempting-dynamic-reference-tags-using-expressions-baffled-by-behavior/74403/14 "2023-06-01T01:33:48Z")

</div>

Lots of options in `system.tag.*`.

---

<div class="post-metadata">

**Author:** ![Peter\_A](https://avatars.discourse-cdn.com/v4/letter/p/cdc98d/32.png) [@Peter\_A](https://forum.inductiveautomation.com/u/Peter_A)\
**Post date:** [May 31, 2024, 3:33pm UTC](https://forum.inductiveautomation.com/t/attempting-dynamic-reference-tags-using-expressions-baffled-by-behavior/74403/15 "2024-05-31T15:33:18Z")

</div>

I want to nest {}'s in a UDT expression tag is there no syntax to make this work? It seems crazy to have to hard code the instance name for each UDT tag. Any help is appreciated.

if({[~]WorkCenters/{InstanceName}/TimerTrigger},now(0),0)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 31, 2024, 3:48pm UTC](https://forum.inductiveautomation.com/t/attempting-dynamic-reference-tags-using-expressions-baffled-by-behavior/74403/16 "2024-05-31T15:48:26Z")

</div>

This is one of the few cases where the `tag()` expression function is appropriate.

---

<div class="post-metadata">

**Author:** ![Peter\_A](https://avatars.discourse-cdn.com/v4/letter/p/cdc98d/32.png) [@Peter\_A](https://forum.inductiveautomation.com/u/Peter_A)\
**Post date:** [May 31, 2024, 4:46pm UTC](https://forum.inductiveautomation.com/t/attempting-dynamic-reference-tags-using-expressions-baffled-by-behavior/74403/17 "2024-05-31T16:46:10Z")

</div>

This worked thank you!!

```python
if(tag('[~]WorkCenters/'+{InstanceName}+'/TimerTrigger'),now(0),0)

```

```python
if({[~]WorkCenters/W2101/TimerTrigger},now(0),0)

```

[tag | Ignition User Manual (inductiveautomation.com)](https://www.docs.inductiveautomation.com/docs/8.1/appendix/expression-functions/advanced/tag)

Thanks for the speedy reply.

---

<div class="post-metadata">

**Author:** ![hunterdg](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/hunterdg/32/67774_2.png) [@hunterdg](https://forum.inductiveautomation.com/u/hunterdg)\
**Post date:** [April 7, 2025, 11:29pm UTC](https://forum.inductiveautomation.com/t/attempting-dynamic-reference-tags-using-expressions-baffled-by-behavior/74403/18 "2025-04-07T23:29:52Z")

</div>

![CleanShot 2025-04-07 at 18.29.01](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/b/1bd22e28708fdba77a5c56eece0ca14ab149bb9e.png)  
what am i missing here?

and why is the [documentation](https://www.docs.inductiveautomation.com/docs/8.1/platform/tags/user-defined-types-udts/udt-parameters#pre-defined-parameters) screenshot half-baked?
