# Expression Variable tag paths

**URL:** <https://forum.inductiveautomation.com/t/expression-variable-tag-paths/88849>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [April 15, 2024, 7:58pm UTC](https://forum.inductiveautomation.com/t/expression-variable-tag-paths/88849 "2024-04-15T19:58:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ryan\_Craig](https://avatars.discourse-cdn.com/v4/letter/r/45deac/32.png) [@Ryan\_Craig](https://forum.inductiveautomation.com/u/Ryan_Craig)\
**Post date:** [April 15, 2024, 7:58pm UTC](https://forum.inductiveautomation.com/t/expression-variable-tag-paths/88849/1 "2024-04-15T19:58:38Z")

</div>

I am in the process of making my project UDT (Had the project working correctly and now I am just setting it up for multiple machines) and having the whole project work dynamically based on the machine number that is running.

I have an expression binding on a few things on my project, and can't seem to figure out how to make it work dynamically.

What I mean by this, is have it look at a tag path for a specific machine Number.  
Here you can see that I have a Property Change script that will write to a tag based on the machine running the program:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/9/e9b792d29f03a7c1da4853fbb6bc7921caea94e0.png)

Is there anyway I can do something similar to this within this expression script?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/0/6062c3527dec03f71cb6064a7b055835cf230249.png)  
Or maybe a better way to approach this problem?

---

<div class="post-metadata">

**Author:** ![kvane](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kvane/32/22228_2.png) [@kvane](https://forum.inductiveautomation.com/u/kvane)\
**Post date:** [April 15, 2024, 8:00pm UTC](https://forum.inductiveautomation.com/t/expression-variable-tag-paths/88849/2 "2024-04-15T20:00:03Z")

</div>

Edited: You can make custom properties that have dynamic indirect tag bindings for the tag values you are interested in, and refer to those custom properties in the expression. This is the best approach because the tag bindings will stay up to date and ensure the UI binding is accurate.

To answer your question on how to use an expression to target a dynamic tag, the tag() expression function allows us to dynamically alter the string representation of a tag path. [tag | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/appendix/expression-functions/advanced/tag)

But as Phil noted, the custom property approach will yield the best results.

---

<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:** [April 15, 2024, 8:04pm UTC](https://forum.inductiveautomation.com/t/expression-variable-tag-paths/88849/3 "2024-04-15T20:04:03Z")

</div>

> [@kvane](#):
>
> Or alternatively you can make custom properties that have dynamic indirect tag bindings

This is the solution, not the alternative. `tag()` does not belong in **any** user interface expression bindings.

---

<div class="post-metadata">

**Author:** ![Ryan\_Craig](https://avatars.discourse-cdn.com/v4/letter/r/45deac/32.png) [@Ryan\_Craig](https://forum.inductiveautomation.com/u/Ryan_Craig)\
**Post date:** [April 15, 2024, 8:10pm UTC](https://forum.inductiveautomation.com/t/expression-variable-tag-paths/88849/4 "2024-04-15T20:10:46Z")

</div>

I do have a custom param that is being used to determine which machine the program is running on:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/7/f7a680a5d9a04e67bb85bd3b33610ef42d9eb38f.png)  
I am just not sure how to reference this within the expression structure.

---

<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:** [April 15, 2024, 8:15pm UTC](https://forum.inductiveautomation.com/t/expression-variable-tag-paths/88849/5 "2024-04-15T20:15:04Z")

</div>

You'll have much more future flexibility if you design your views to take a single `tagpath` parameter, containing the entire provider and folder name (or UDT instance name), not just part of a tag path. Instead of `ENumber`: `E398`, it would be `tagpath`: `[default]E398/E398/JobscanInfo/` or similar. (You probably should avoid the double naming in your hierarchy.)

Then your indirect binding looks like `{1}JobScan` where `{1}` is tied to `view.params.tagpath`. (Don't tie to a session variable except at the **page** level, so it all cascades inward.)

---

<div class="post-metadata">

**Author:** ![Ryan\_Craig](https://avatars.discourse-cdn.com/v4/letter/r/45deac/32.png) [@Ryan\_Craig](https://forum.inductiveautomation.com/u/Ryan_Craig)\
**Post date:** [April 15, 2024, 8:23pm UTC](https://forum.inductiveautomation.com/t/expression-variable-tag-paths/88849/6 "2024-04-15T20:23:50Z")

</div>

I was able to get this to work! Thanks for the help!
