# Use a tag's Value as a part of another OPC Tag's path

**URL:** <https://forum.inductiveautomation.com/t/use-a-tags-value-as-a-part-of-another-opc-tags-path/16209>\
**Category:** Ignition\
**Created:** [December 4, 2017, 7:55pm UTC](https://forum.inductiveautomation.com/t/use-a-tags-value-as-a-part-of-another-opc-tags-path/16209 "2017-12-04T19:55:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sparkblender](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sparkblender/32/4373_2.png) [@Sparkblender](https://forum.inductiveautomation.com/u/Sparkblender)\
**Post date:** [December 4, 2017, 7:55pm UTC](https://forum.inductiveautomation.com/t/use-a-tags-value-as-a-part-of-another-opc-tags-path/16209/1 "2017-12-04T19:55:26Z")

</div>

Hello Everybody.

I was wondering if it would be possible to construct a Tag’s source path (e.g. an OPC Tag’s path) by using a combination of strings and dynamic Values from other tags.

For instance, I have two UDT instances called _Plc_, stored in the Device1 and Device2 folder respectively, like so:

**MyTags/Devices/Device1** /Plc/DeviceName  
**MyTags/Devices/Device2** /Plc/DeviceName

The Plc UDT contains a tag called PlcDeviceName.

Now, each PLC contains a software module called ModuleA, which I model like so:

**MyTags/Devices/Device1/Modules** /Cooker/Pressure  
**MyTags/Devices/Device2/Modules** /Cooker/Pressure

In both cases, _Cooker_ are instances of a UDT called _Cooker_, which contains an OPC Tag called _Pressure_.

What I’m trying to do is to define a dynamic OPC path for _Pressure_, like so:

[{[.]…/…/Plc/DeviceName}]DB100,I8

which references integer 8 within data block 100 of the underlying SIEMENS PLC (Device1 or Device2 respectively).

I understand the above syntax doesn’t work; I just used it to illustrate my question with an example.  
My questions in short:

- Is it possible to define dynamic OPC paths?
- If so, how?
- If not directly possible, can we use some advanced scripting technique to achieve the same results?

Thanks.

---

<div class="post-metadata">

**Author:** ![Sparkblender](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sparkblender/32/4373_2.png) [@Sparkblender](https://forum.inductiveautomation.com/u/Sparkblender)\
**Post date:** [December 10, 2017, 10:27pm UTC](https://forum.inductiveautomation.com/t/use-a-tags-value-as-a-part-of-another-opc-tags-path/16209/2 "2017-12-10T22:27:17Z")

</div>

Here’s an update of what I’ve been able to accomplish so far.

Based on the following example, this is the result:

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/8/8184c98881d026b93b64ab1a133f506fa25c2403.jpg)

I’ve been able to construct a script string by referencing other tags, using the relative tag path, like so:

**OpcItemPath Expression Tag’s expression:**

```auto
"[" + tag('[.]../../Plc/DeviceName') + "]" + "DB733,I8"

```

**Script Expression Tag’s expression:**

```auto
"shared.pcsmis.opc.readValue('" + tag('[.]OpcItemPath') + "')"

```

The returned string stored in the “Script” tag is:  
`shared.pcsmis.opc.readValue('[S1P01]DB733,I8')`

This is the global script that returns the OPC value, and it works great as I tested it on its own:

```auto
def getOpcServerName():
	return 'Ignition OPC-UA Server' 
	
def readValue(item_path):
	return system.opc.readValue(getOpcServerName(), item_path)

```

The only problem I still have is, how to run the script successfully from the Pressure Expression Tag.

**Pressure Expression Tag’s expression:**

```auto
runScript( toString( tag('[.]Script') ) )

```

This is the error displayed under Tag Diagnostics:

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/f/f07e74e74db94026187486d5a752d0304d5e00d1.jpg)

Anyone knows what this error means?

Thanks.

---

<div class="post-metadata">

**Author:** ![Frank\_Pockele](https://avatars.discourse-cdn.com/v4/letter/f/7bcc69/32.png) [@Frank\_Pockele](https://forum.inductiveautomation.com/u/Frank_Pockele)\
**Post date:** [October 12, 2026, 12:48pm UTC](https://forum.inductiveautomation.com/t/use-a-tags-value-as-a-part-of-another-opc-tags-path/16209/3 "2026-10-12T12:48:17Z")

</div>

Hello, did you found a solution for this, i'm looking for something simular?

---

<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:** [October 12, 2026, 12:55pm UTC](https://forum.inductiveautomation.com/t/use-a-tags-value-as-a-part-of-another-opc-tags-path/16209/4 "2026-10-12T12:55:51Z")

</div>

You should start a new post and share exactly what you are trying to do, what you **have** tried, and precise results so far.

---

<div class="post-metadata">

**Author:** ![Sparkblender](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sparkblender/32/4373_2.png) [@Sparkblender](https://forum.inductiveautomation.com/u/Sparkblender)\
**Post date:** [October 12, 2026, 1:49pm UTC](https://forum.inductiveautomation.com/t/use-a-tags-value-as-a-part-of-another-opc-tags-path/16209/5 "2026-10-12T13:49:19Z")

</div>

@Frank_Pockele As you may have noticed, I haven't looked at this in a while 😀  
Please message me here to let me know if you are starting a new post to find an answer to this problem. Believe it or not, I'm still interested in finding an answer.  
Cheers 👍

---

<div class="post-metadata">

**Author:** ![sylee](https://avatars.discourse-cdn.com/v4/letter/s/f4b2a3/32.png) [@sylee](https://forum.inductiveautomation.com/u/sylee)\
**Post date:** [October 23, 2026, 7:22am UTC](https://forum.inductiveautomation.com/t/use-a-tags-value-as-a-part-of-another-opc-tags-path/16209/6 "2026-10-23T07:22:22Z")

</div>

I’ve run into the same issue, but I haven’t found a solution either.🥲
