# How to change dynamically the source tag path of a Reference Tag

**URL:** <https://forum.inductiveautomation.com/t/how-to-change-dynamically-the-source-tag-path-of-a-reference-tag/101662>\
**Category:** Ignition\
**Created:** [January 31, 2025, 9:44am UTC](https://forum.inductiveautomation.com/t/how-to-change-dynamically-the-source-tag-path-of-a-reference-tag/101662 "2025-01-31T09:44:49Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mushu](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@Mushu](https://forum.inductiveautomation.com/u/Mushu)\
**Post date:** [January 31, 2025, 9:44am UTC](https://forum.inductiveautomation.com/t/how-to-change-dynamically-the-source-tag-path-of-a-reference-tag/101662/1 "2025-01-31T09:44:49Z")

</div>

Hi,

I’m trying to dynamically build the source tag path of a Reference Tag.

I have been reading this post but I cannot make it work.

> [@Dynamically build source tag path for Reference Tag from other tag value](https://forum.inductiveautomation.com/t/dynamically-build-source-tag-path-for-reference-tag-from-other-tag-value/83724):
>
> Hello all, Is there a way to dynamically build the source tag path of a Reference Tag? I have a structure similar to the following: [image] (just pretend that the PLC tag is actually connected) What I'm trying to do is have the Temperature tag reference either the MEM/Temperature tag or the PLC/Temperature tag, based on the value of the Config tag: that is, if Config has value "MEM", I want Temperature to reference MEM/Temperature, whereas if Config has value "PLC", I want Temperature to re…

I have a UDT, Probe\_UDT, with a tag to read temperature, PV:

> **Probe\_UDT**
>
> ```python
> {
> "name": "Probe_UDT",
> "typeId": "",
> "tagType": "UdtType",
> "tags": [
> {
> "name": "01_Inputs",
> "tagType": "Folder",
> "tags": [
> {
> "opcItemPath": {
> "bindType": "parameter",
> "binding": "ns\u003d1;s\u003d[Sample_Device]_Meta:Ramp/Ramp{TankNumber}"
> },
> "valueSource": "memory",
> "expression": "dateExtract(now(), \"sec\")",
> "dataType": "Float4",
> "historyProvider": "IGN_Historian",
> "name": "PV",
> "historyEnabled": false,
> "tagType": "AtomicTag",
> "opcServer": "Ignition OPC UA Server"
> }
> ]
> }
> ]
> }
> 
> ```

I have mobile tanks that can get their temperature reading from a different probe, depending their position. So I have a UDT, CoolTank\_UDT, to handle tanks. One of the fields is a reference tag. I would like to change dynamically its “Source Tag Path” to point the relevant temperature probe.

I tried to build the “Source Tag Path” at the reference tag, but it didn’t work; the expression wasn’t executing. So I added an expression tag to build the probe tag path and added the expression tag in the “Source Tag Path” of the reference tag. But it doesn’t work neither.

PV\_Path expression tag expression:  
`{[.]TankPath} + "/" + {[.]Probe} + "/01_Inputs/PV"`

CookTank\_UDT Jason definition:

> **CookTank\_UDT**
>
> ```python
> 
> {
> "name": "CoolTank_UDT",
> "typeId": "",
> "tagType": "UdtType",
> "tags": [
> {
> "name": "01_Inputs",
> "tagType": "Folder",
> "tags": [
> {
> "valueSource": "memory",
> "dataType": "String",
> "name": "Probe",
> "tagType": "AtomicTag"
> },
> {
> "valueSource": "expr",
> "expression": "{[.]TankPath} + \"/\" + {[.]Probe} + \"/01_Inputs/PV\"",
> "dataType": "String",
> "name": "PV_Path",
> "tagType": "AtomicTag"
> },
> {
> "valueSource": "memory",
> "dataType": "String",
> "name": "TankPath",
> "tagType": "AtomicTag"
> },
> {
> "sourceTagPath": {
> "bindType": "parameter",
> "binding": "{[.]PV_Path}"
> },
> "valueSource": "reference",
> "dataType": "Float4",
> "name": "PV",
> "tagType": "AtomicTag"
> }
> ]
> }
> ]
> }
> 
> ```

Example:  
Probe tag:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/4/54369d389d10f7ccae34686e6eb25c5ab00e0dfe.png)

Tank tag: PV\_Path has the right path to Probe1 PV, but Tank 1 PV SourceTagPath doesn’t get the value of PV\_Path (I have tried with [.]PV\_Path, without the {} too, with the same result):

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/3/538a3e8b7c16bd749d61c47c7205b26bd2459a94.jpeg)  
If I harcoded the value in PV\_Path in the “Source Tag Path” of the reference tag (PV), it works.  
Do you know why the “Source Tag Path” doesn’t get compiled?

---

<div class="post-metadata">

**Author:** ![Gaurav.Shitole](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/gaurav.shitole/32/72050_2.png) [@Gaurav.Shitole](https://forum.inductiveautomation.com/u/Gaurav.Shitole)\
**Post date:** [January 31, 2025, 11:15am UTC](https://forum.inductiveautomation.com/t/how-to-change-dynamically-the-source-tag-path-of-a-reference-tag/101662/2 "2025-01-31T11:15:57Z")

</div>

Can you try adding `tag()` function in your **PV\_Path** tag expression?

So in your case it should be like `tag([default]Probes/Probe1/01_Inputs/PV)`.

---

<div class="post-metadata">

**Author:** ![Mushu](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@Mushu](https://forum.inductiveautomation.com/u/Mushu)\
**Post date:** [January 31, 2025, 12:02pm UTC](https://forum.inductiveautomation.com/t/how-to-change-dynamically-the-source-tag-path-of-a-reference-tag/101662/3 "2025-01-31T12:02:29Z")

</div>

Thank you for your reply.  
I tried as you said but I had these errors:

PV\_Path expression now:  
`"tag(" + {[.]TankPath} + "/" + {[.]Probe} + "/01_Inputs/PV)"`

PV\_Path value:  
`tag([default]Probes/Probe1/01_Inputs/PV)`

If PV reference tag “Source Tag Path”:

```python
[.]PV_Path

```

PV reference tag quality:  
`Error_TypeConversion("Error trying to coerce 'tag([default]Probes/Probe1/01_Inputs/PV)' to a number.")`

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/9/0967435affc3a1b19affbf185a0dea5de1fc165f.jpeg)

I don’t know why it happened this error as: [default]Probes/Probe1/01\_Inputs/PV is a Float and Quality is good.

If PV reference tag “Source Tag Path”:

> {[.]PV\_Path}

PV reference tag quality:  
`Error_Configuration`

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/2/e25e87b881d232e5a3765ad906a2689f67b0323a.jpeg)

---

<div class="post-metadata">

**Author:** ![Gaurav.Shitole](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/gaurav.shitole/32/72050_2.png) [@Gaurav.Shitole](https://forum.inductiveautomation.com/u/Gaurav.Shitole)\
**Post date:** [January 31, 2025, 12:34pm UTC](https://forum.inductiveautomation.com/t/how-to-change-dynamically-the-source-tag-path-of-a-reference-tag/101662/4 "2025-01-31T12:34:22Z")

</div>

Your **PV\_Path** should be a **string** :

```python
PV_Path.value = tag('[default]Probes/Probe1/01_Inputs/PV')

```

And **PV** should be a **Float**. With this setup, it should work correctly.

Make sure **PV\_Path** is enclosed in **quotes** when assigning its value.

---

<div class="post-metadata">

**Author:** ![Mushu](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@Mushu](https://forum.inductiveautomation.com/u/Mushu)\
**Post date:** [January 31, 2025, 1:12pm UTC](https://forum.inductiveautomation.com/t/how-to-change-dynamically-the-source-tag-path-of-a-reference-tag/101662/5 "2025-01-31T13:12:27Z")

</div>

Thanks again for you quick reply.

I confirm that PV\_Path is data type String; the value source is expression.

I have updated the expression to get the value that you indicated:

> "tag('"+ {[.]TankPath} + "/" + {[.]Probe} + "/01\_Inputs/PV')"

> PV\_Path.value = tag('[default]Probes/Probe1/01\_Inputs/PV')

I confirm that:

PV in the CoolTank \_UDT is data type Float and value source Reference

PV in the probe type is data type Float and value source Memory

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

If I hardcode the Source Tag Path to PV in the CoolTank\_UDT:  
`[default]Probes/Probe1/01_Inputs/PV`

it works:

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

I don't know it doesn't work when I add the string value from PV\_Path

---

<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:** [January 31, 2025, 1:12pm UTC](https://forum.inductiveautomation.com/t/how-to-change-dynamically-the-source-tag-path-of-a-reference-tag/101662/6 "2025-01-31T13:12:35Z")

</div>

Tag configuration parameters like source tag path cannot bind to tags. They can only bind to UDT parameters. Only actual expression tags can freely bind to anything.

You will need to use a script to **write** to that configuration property when necessary.

Caveat: Alarm properties can also bind to anything, but are only executed on alarm events. They do not track any references.

---

<div class="post-metadata">

**Author:** ![Mushu](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@Mushu](https://forum.inductiveautomation.com/u/Mushu)\
**Post date:** [January 31, 2025, 1:22pm UTC](https://forum.inductiveautomation.com/t/how-to-change-dynamically-the-source-tag-path-of-a-reference-tag/101662/7 "2025-01-31T13:22:44Z")

</div>

Thank you very much.  
This script worked:

```python
path = "[default]Tanks/Tank1/01_Inputs/PV.SourceTagPath"
value = "[default]Probes/Probe1/01_Inputs/PV"
system.tag.writeBlocking(path,value)

```

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/8/58c3ceb16b93150acfc4586d4cafa5a4dcbd94db.png)

Thanks again to Gaurav and pturmel.
