# Is there an inverse of the Advanced -\> tag() scripting function, one that can write by reference?

**URL:** <https://forum.inductiveautomation.com/t/is-there-an-inverse-of-the-advanced-tag-scripting-function-one-that-can-write-by-reference/104203>\
**Category:** Ignition\
**Tags:** ignition81, vision\
**Created:** [March 25, 2025, 9:50pm UTC](https://forum.inductiveautomation.com/t/is-there-an-inverse-of-the-advanced-tag-scripting-function-one-that-can-write-by-reference/104203 "2025-03-25T21:50:00Z")\
**Posts on this page:** 20\
**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:** [March 25, 2025, 9:50pm UTC](https://forum.inductiveautomation.com/t/is-there-an-inverse-of-the-advanced-tag-scripting-function-one-that-can-write-by-reference/104203/1 "2025-03-25T21:50:00Z")

</div>

I have long since figured out the (hacky) way of reading tags "indirectly" using the `tag()` method in the expression language. Is there the opposite, that would let me write by reference? Do I need to make a basic script that calls `system.tag.writeBlocking` on the referenced tag and then uses runScript to execute it on an event trigger? I would expect this to be slow and have stability questions compared to using a builtin system, if one exists.

What I really want is `tag(tagPath)` to actually be `tag(tagPath, [writeValue])` where it optionally will write the value to the tag instead of returning the value.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [March 25, 2025, 9:50pm UTC](https://forum.inductiveautomation.com/t/is-there-an-inverse-of-the-advanced-tag-scripting-function-one-that-can-write-by-reference/104203/2 "2025-03-25T21:50:59Z")

</div>

There's not, and expressions having side effects is discouraged in general. `runScript` is an escape hatch to be used with caution.

---

<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:** [March 25, 2025, 9:51pm UTC](https://forum.inductiveautomation.com/t/is-there-an-inverse-of-the-advanced-tag-scripting-function-one-that-can-write-by-reference/104203/3 "2025-03-25T21:51:45Z")

</div>

So there is basically no way to have a dynamically referenced tag system with writing capability that is supported?

I.e. if I have 5 identical systems that have "system1" "system2"... names, where each system recieves a block of PLC Modbus registers that are structurally identical and only vary with the name of the folder they are in, I can't just duplicate the tag provider and adjust their reference to modbus input tags by name?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [March 25, 2025, 9:52pm UTC](https://forum.inductiveautomation.com/t/is-there-an-inverse-of-the-advanced-tag-scripting-function-one-that-can-write-by-reference/104203/4 "2025-03-25T21:52:16Z")

</div>

I haven't been following your multi post dynamic tag saga close enough to say yes or no to that.

---

<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:** [March 25, 2025, 9:53pm UTC](https://forum.inductiveautomation.com/t/is-there-an-inverse-of-the-advanced-tag-scripting-function-one-that-can-write-by-reference/104203/5 "2025-03-25T21:53:17Z")

</div>

Bidirectional tag bindings in user interfaces do this. Expressions cannot. Derived tags and reference tags are also bidirectional, and the latter can be easily reconfigured.

---

<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:** [March 25, 2025, 9:53pm UTC](https://forum.inductiveautomation.com/t/is-there-an-inverse-of-the-advanced-tag-scripting-function-one-that-can-write-by-reference/104203/6 "2025-03-25T21:53:52Z")

</div>

> [@sherman](#):
>
> I.e. if I have 5 identical systems that have "system1" "system2"... names, where each system recieves a block of PLC Modbus registers that are structurally identical and only vary with the name of the folder they are in, I can't just duplicate the tag provider and adjust their reference to modbus input tags by name?

Derived tags and reference tags are incapable of dynamic tag pathing, no?

---

<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:** [March 25, 2025, 9:55pm UTC](https://forum.inductiveautomation.com/t/is-there-an-inverse-of-the-advanced-tag-scripting-function-one-that-can-write-by-reference/104203/7 "2025-03-25T21:55:02Z")

</div>

> [@sherman](#):
>
> I can't just duplicate the tag provider and adjust their reference to modbus input tags by name?

No, but you can make a UDT that has that repeating structure, and make multiple, identical PLC instances in one tag provider.

(You are really hung up on having per-project tag providers. It runs against the grain of Ignition's architecture.)

---

<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:** [March 25, 2025, 9:56pm UTC](https://forum.inductiveautomation.com/t/is-there-an-inverse-of-the-advanced-tag-scripting-function-one-that-can-write-by-reference/104203/8 "2025-03-25T21:56:24Z")

</div>

Both kinds can have configuration-time dynamic pathing by including them in UDTs. Which are the foundation elements of Ignition's dynamic configuration capabilities.

---

<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:** [March 25, 2025, 9:56pm UTC](https://forum.inductiveautomation.com/t/is-there-an-inverse-of-the-advanced-tag-scripting-function-one-that-can-write-by-reference/104203/9 "2025-03-25T21:56:29Z")

</div>

Actually, I have been trying very very hard to avoid the per-project tag provider, it is not until literally today that I even tried to implement a project-specific tag provider. Since I can't seem to use that to fetch the project name for steering, it is not useful to me.

---

<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:** [March 25, 2025, 9:57pm UTC](https://forum.inductiveautomation.com/t/is-there-an-inverse-of-the-advanced-tag-scripting-function-one-that-can-write-by-reference/104203/10 "2025-03-25T21:57:45Z")

</div>

Can you show me an example of how this works? I have tried every which way I can think of and it will not resolve the value of the dynamic tag in a Reference or a Derived tag, I have to use `tag()` inside of an expression tag.

---

<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:** [March 25, 2025, 9:58pm UTC](https://forum.inductiveautomation.com/t/is-there-an-inverse-of-the-advanced-tag-scripting-function-one-that-can-write-by-reference/104203/11 "2025-03-25T21:58:51Z")

</div>

**configuration-time** dynamic references. Anything else is crazy talk within tags, and belongs in user interfaces.

---

<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:** [March 25, 2025, 10:01pm UTC](https://forum.inductiveautomation.com/t/is-there-an-inverse-of-the-advanced-tag-scripting-function-one-that-can-write-by-reference/104203/12 "2025-03-25T22:01:08Z")

</div>

> **configuration-time** dynamic references. Anything else is crazy talk within tags, and belongs in user interfaces.

Ah, that sucks. I have that solved for my first bridge layer but I am trying to implement the "user interface" layer which is a lot more handmade and not something that I can trivially script into a configuration without some kind of bootstrapped "read the stuff that developers wrote and rewrite it all so that it can be duplicated" type of procedure.

Basically, I want to duplicate our system so we can run two in parallel and I don't want to manually update every single tag reference by changing a 1 to a 2 in a path in order to do it. I've solved this at the binding level in Vision but I am clearly struggling to abstract the actual memory layer of Ignition which is exceptionally frustrating as a python developer.

---

<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:** [March 25, 2025, 10:04pm UTC](https://forum.inductiveautomation.com/t/is-there-an-inverse-of-the-advanced-tag-scripting-function-one-that-can-write-by-reference/104203/13 "2025-03-25T22:04:13Z")

</div>

> [@sherman](#):
>
> single tag reference by changing a 1 to a 2 in a path

If you use UDTs, you can have a parameter for that part of the path, and change it in one place for the entire UDT instance. That is what they are _ **for** _.

I recommend to take a look at my Spreadsheet Import Tool on the Exchange, including its example UDT definitions and the example spreadsheets that drive instance creation/replacement.

If you intend to run two PLCs in parallel, make two UDT instances that are parameterized to point into the PLCs correctly.

Then you make your UI take a tag path parameter that points at one or the other UDT instance path. Key everything in your UI off of indirect bindings with that parameter. Pass that parameter inward to subsystems, possibly with added path name fragments.

---

<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:** [March 25, 2025, 10:09pm UTC](https://forum.inductiveautomation.com/t/is-there-an-inverse-of-the-advanced-tag-scripting-function-one-that-can-write-by-reference/104203/14 "2025-03-25T22:09:18Z")

</div>

> If you use UDTs, you can have a parameter for that part of the path, and change it in one place for the entire UDT instance. That is what they are _ **for** _ .

I have that, what I am missing is the part of the UDT that lets me **write** back to the referenced tags.

I can read them

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/a/ba6c6f19accac85dcda48002d5550223c2b067b5.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/1/a13ecf6328b426ab74322d48ae29e4f8d042aeec.png)

But this doesn't work to write them because there is no write equivalent to `tag()`

---

<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:** [March 25, 2025, 10:10pm UTC](https://forum.inductiveautomation.com/t/is-there-an-inverse-of-the-advanced-tag-scripting-function-one-that-can-write-by-reference/104203/15 "2025-03-25T22:10:18Z")

</div>

> Then you make your UI take a tag path parameter that points at one or the other UDT instance path. Key everything in your UI off of indirect bindings with that parameter. Pass that parameter inward to subsystems, possibly with added path name fragments.

Are you effectively suggesting I offload the "find the source tag and write to it" logic all the way into the actual bindings of components in the gui?

---

<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:** [March 25, 2025, 10:11pm UTC](https://forum.inductiveautomation.com/t/is-there-an-inverse-of-the-advanced-tag-scripting-function-one-that-can-write-by-reference/104203/16 "2025-03-25T22:11:07Z")

</div>

Get rid of `tag()`, too. Make your UDT point at the PLC based on its parameters. Make the member names and inner folders/nested UDTs fit the structure you need for your UI.

Get **rid** of the runtime indirection in your tags.

---

<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:** [March 25, 2025, 10:14pm UTC](https://forum.inductiveautomation.com/t/is-there-an-inverse-of-the-advanced-tag-scripting-function-one-that-can-write-by-reference/104203/17 "2025-03-25T22:14:20Z")

</div>

> [@sherman](#):
>
> actual bindings of components in the gui?

Yes, but every such "find" is simple concatenation of the outer tag path with a constant string for the inner reference. Then your indirect tag bindings both bring data to your UI for display _ **and** _ provide the write path.

If your PLCs have the same structure, then all tags and folders (or nested UDTs) should have the same names, except the outermost fragment. That outermost fragment is what you pass to the outermost view of your UI. (Or Window, in Vision.)

---

<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:** [March 25, 2025, 10:21pm UTC](https://forum.inductiveautomation.com/t/is-there-an-inverse-of-the-advanced-tag-scripting-function-one-that-can-write-by-reference/104203/18 "2025-03-25T22:21:55Z")

</div>

This is a sort of example of my system architecture. My goal is to have all my "variables" available for GUI developers to be able to make an interface, while keeping as little strange logic in the HMI itself as possible. I am developing a platform for R&D applications where we iterate quite a lot and systems will sort of start as copies and then mutate over time. I do **not want** any of the controls to have the possibility to accidentally grab the wrong PLC, so I am trying to keep everything as abstracted as possible such that there are a few high level switches that control the flow.

Notably missing from the graphic is the fact that our PLCs expose blocks of Modbus memory that I have attached to via the OPCUA configuration in the Gateway interface:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/3/23c412b8faaa2590ac3ef44242b7b96e85dac615.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/0/d0d30a1011aa37b9a13b96ab8836a1f3c8c56315.png)

---

<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:** [March 25, 2025, 10:25pm UTC](https://forum.inductiveautomation.com/t/is-there-an-inverse-of-the-advanced-tag-scripting-function-one-that-can-write-by-reference/104203/19 "2025-03-25T22:25:49Z")

</div>

Good luck. Your architecture implies that a PLC change is not a configuration change. The Modbus mappings in IA's driver are a crutch that even the author that driver recommends against using. Just make manual OPC Item Paths in your OPC tags.

{Do take a moment, perhaps when you are frustrated, to look at my Spreadsheet Import Tool.}

---

<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:** [March 25, 2025, 10:27pm UTC](https://forum.inductiveautomation.com/t/is-there-an-inverse-of-the-advanced-tag-scripting-function-one-that-can-write-by-reference/104203/20 "2025-03-25T22:27:15Z")

</div>

> Your architecture implies that a PLC change is not a configuration change.

I don't think I understand what you mean by this -- when I change something in my PLC (and more importantly where those changes affect where data hits the modbus interface), I have to run my script to reconfigure my tags to align with the new PLC arrangement. What does "configuration change" mean to you?

[Next page](https://forum.inductiveautomation.com/t/is-there-an-inverse-of-the-advanced-tag-scripting-function-one-that-can-write-by-reference/104203.md?page=2)
