# How to change opcItemPath's using scripting on UDT's that have a 'binding' that uses parameters

**URL:** <https://forum.inductiveautomation.com/t/how-to-change-opcitempaths-using-scripting-on-udts-that-have-a-binding-that-uses-parameters/105184>\
**Category:** Ignition\
**Tags:** ignition81, scripting\
**Created:** [April 16, 2025, 4:35pm UTC](https://forum.inductiveautomation.com/t/how-to-change-opcitempaths-using-scripting-on-udts-that-have-a-binding-that-uses-parameters/105184 "2025-04-16T16:35:42Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Everett\_Cass](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/everett_cass/32/86983_2.png) [@Everett\_Cass](https://forum.inductiveautomation.com/u/Everett_Cass)\
**Post date:** [April 16, 2025, 4:35pm UTC](https://forum.inductiveautomation.com/t/how-to-change-opcitempaths-using-scripting-on-udts-that-have-a-binding-that-uses-parameters/105184/1 "2025-04-16T16:35:42Z")

</div>

Here is my tag:

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

Here is the UDT:

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

Notice the OPC Item Path uses a binding that involves parameters in the tag.

```python
{
  "parameters": {
    "SensorLocation": {
      "dataType": "String",
      "value": "A01.2 Reach-In Frozen"
    }
  },
  "name": "CleanModeSts",
  "tagType": "UdtInstance",
  "tags": [
    {
      "name": "Value",
      "tagType": "AtomicTag"
    },
    {
      "name": "ValueOverrideTimerSP",
      "tagType": "AtomicTag"
    },
    {
      "name": "HighestAlarmPri",
      "tagType": "AtomicTag"
    },
    {
      "name": "ValueOverrideMode",
      "tagType": "AtomicTag"
    }
  ]
}

```

Here is the json, it makes sense since there are no overrides, the opcItemPath doesn't exist. However when I try and script an opcItemPath change like this:

```python
path = '[014Edge]Beaverton/Refrigeration/Rack1/A01/Case02/CleanModeSts'
system.tag.writeBlocking(path+'.opcItemPath','Test')
print(system.tag.readBlocking(path+'.opcItemPath')[0].value)

```

The console read's back

> [Good]  
> Test

and when I copy the tag JSON I get:

```python
{
  "opcItemPath": "Test",
  "parameters": {
    "SensorLocation": {
      "dataType": "String",
      "value": "A01.1 Reach-In Frozen"
    }
  },
  "name": "CleanModeSts",
  "tagType": "UdtInstance",
  "tags": [
    {
      "name": "HighestAlarmPri",
      "tagType": "AtomicTag"
    },
    {
      "name": "ValueOverrideTimerSP",
      "tagType": "AtomicTag"
    },
    {
      "name": "Value",
      "tagType": "AtomicTag"
    },
    {
      "name": "ValueOverrideMode",
      "tagType": "AtomicTag"
    }
  ]
}

```

Which looks great. HOWEVER... when I open the tag editor it looks like this:  
And it appears to take priority over the binding rather than the overwritten opcItemPath 'Test' (Which should give an error configuration)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/9/0975c13e9f7d540f3c010b1d8e5d2e76eb08271b.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/2/b2749887a232924f931b2e8e9b2a2911dbb76a04.png)

The tag server is on 8.1.21, so to me it would seem like a bug. Not sure if this is fixed on newer versions.  
But any clarity onto why this might be the case and the overwrite isn't actually setting would be greatly appreciated.

---

<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 16, 2025, 9:33pm UTC](https://forum.inductiveautomation.com/t/how-to-change-opcitempaths-using-scripting-on-udts-that-have-a-binding-that-uses-parameters/105184/2 "2025-04-16T21:33:26Z")

</div>

If the OPC item path is a value determined by an internal binding on the UDT definition then update the parameters that drive that binding do not try to override the actual value. This sounds expected.

You can create a new param that represents the whole item path and do what you are describing by writing to the parameter.

Why are you trying to overwrite the opc item path if it is already determined by the outcome of the binding. Doesn't the binding already exists to represent dynamic paths for this UDT?

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [April 16, 2025, 9:53pm UTC](https://forum.inductiveautomation.com/t/how-to-change-opcitempaths-using-scripting-on-udts-that-have-a-binding-that-uses-parameters/105184/3 "2025-04-16T21:53:53Z")

</div>

You're trying to write to the _UDT instance's_ opcitempath, not its Value tag

Ie the path should be:

```python
path = '[014Edge]Beaverton/Refrigeration/Rack1/A01/Case02/CleanModeSts/Value'
system.tag.writeBlocking(path+'.opcItemPath','Test')

```

The former just added a custom prop to the UDT instance which just holds a value, nothing functional

---

<div class="post-metadata">

**Author:** ![Everett\_Cass](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/everett_cass/32/86983_2.png) [@Everett\_Cass](https://forum.inductiveautomation.com/u/Everett_Cass)\
**Post date:** [April 17, 2025, 3:25pm UTC](https://forum.inductiveautomation.com/t/how-to-change-opcitempaths-using-scripting-on-udts-that-have-a-binding-that-uses-parameters/105184/4 "2025-04-17T15:25:38Z")

</div>

Well we have a many stores that use these UDT’s and on occasion the program will have a minor difference needing a manual override for the Opc Item Path. But typically we do this through scripting as it’s far more efficient.  
I mean that is the whole point of being able to override a default right? And if I can do it manually through the tag editor why shouldn’t I be able to do it automatically through scripting

I’m not sure why this would be the intended way for this to function, it should work the same way everything else works in ignition, where it takes the default UDT properties unless an override is made which then it should accept that override.

And I could make the whole path a parameter but that also defeats the purpose because at the parent level tag I want to specify a device and a system number. Not every opcItemPath that’s under that parent tag it just doesn’t make sense to do it like that, at that point I might as well manually fill in every opcItemPath as the parameter would serve no actual purpose

---

<div class="post-metadata">

**Author:** ![vtran](https://avatars.discourse-cdn.com/v4/letter/v/779978/32.png) [@vtran](https://forum.inductiveautomation.com/u/vtran)\
**Post date:** [April 17, 2025, 3:38pm UTC](https://forum.inductiveautomation.com/t/how-to-change-opcitempaths-using-scripting-on-udts-that-have-a-binding-that-uses-parameters/105184/5 "2025-04-17T15:38:22Z")

</div>

I don't think you can use `system.tag.writeBlocking` to change a binding, use `system.tag.configure` instead. [system.tag.configure | Ignition User Manual](https://docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-tag/system-tag-configure)  
Something like this

```python
basePath = "[014Edge]Beaverton/Refrigeration/Rack1/A01/Case02/CleanModeSts/"
tags = [{
  "name": "Value", 
  "opcItemPath": {
    "bindType": "parameter",
    "binding": "<your new binding>"
  }
}]
collisionPolicy	= "m" #MergeOverwrite to update only the opcItemPath
system.tag.configure(basePath, tags, collisionPolicy)

```

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [April 17, 2025, 3:38pm UTC](https://forum.inductiveautomation.com/t/how-to-change-opcitempaths-using-scripting-on-udts-that-have-a-binding-that-uses-parameters/105184/6 "2025-04-17T15:38:46Z")

</div>

> [@Everett\_Cass](#):
>
> I’m not sure why this would be the intended way for this to function, it should work the same way everything else works in ignition, where it takes the default UDT properties unless an override is made which then it should accept that override.

Because, you're not creating an override, you're writing a new value to a property, which already has a defined value provided by a binding. This is similar to trying to write a new value to an OPC Tag Value which is being written from the PLC. The write is successful but then is immediately overwritten by the PLC.

To create an override in scripting you would need to use `system.tag.configure()` on the UDT instance to configure the appropriate property.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [April 19, 2025, 1:10am UTC](https://forum.inductiveautomation.com/t/how-to-change-opcitempaths-using-scripting-on-udts-that-have-a-binding-that-uses-parameters/105184/7 "2025-04-19T01:10:33Z")

</div>

> [@nminchin](#):
>
> You're trying to write to the _UDT instance's_ opcitempath, not its Value tag
> 
> Ie the path should be:
> 
> ```python
> path = '[014Edge]Beaverton/Refrigeration/Rack1/A01/Case02/CleanModeSts/Value'
> system.tag.writeBlocking(path+'.opcItemPath','Test')
> 
> ```
> 
> The former just added a custom prop to the UDT instance which just holds a value, nothing functional

I refer you back to my post further up.

_ **It IS possible to override the opcItemPath of a tag inside a UDT Instance that has a binding** _

This below will apply an override to the value of the opcItemPath property on the tag in the udt instance:

```python
system.tag.writeBlocking(
	'Testing/New Instance/New Tag.OPCItemPath',
	'ns=1;s=[WyS]WyS_Sch.RFV01.Event[0].EndDateTimeEpoch'
)

```

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

This is the UDT definition for "New Instance"

```python
{
  "name": "New Type",
  "tagType": "UdtType",
  "tags": [
    {
      "opcItemPath": {
        "bindType": "parameter",
        "binding": "ns\u003d1;s\u003d[{PLCName}]WyA_Net.WyA_AVR.Healthy"
      },
      "valueSource": "opc",
      "name": "New Tag",
      "tagType": "AtomicTag",
      "opcServer": "Ignition OPC-UA Server"
    }
  ]
}

```

> [@Everett\_Cass](#):
>
> However when I try and script an opcItemPath change like this:
> 
> ```python
> path = '[014Edge]Beaverton/Refrigeration/Rack1/A01/Case02/CleanModeSts'
> system.tag.writeBlocking(path+'.opcItemPath','Test')
> print(system.tag.readBlocking(path+'.opcItemPath')[0].value)
> 
> ```

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

When you did this, you added a custom property to the UDT Instance called "opcItemPath" and set its value to "Test". A UDT Instance does not have functionality that uses a property called "opcItemPath", only an atomic 'opc' tag has functionality for this property. You need to write this to an actual atomic tag, not to the UDT instance

---

<div class="post-metadata">

**Author:** ![Everett\_Cass](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/everett_cass/32/86983_2.png) [@Everett\_Cass](https://forum.inductiveautomation.com/u/Everett_Cass)\
**Post date:** [April 21, 2025, 4:08pm UTC](https://forum.inductiveautomation.com/t/how-to-change-opcitempaths-using-scripting-on-udts-that-have-a-binding-that-uses-parameters/105184/8 "2025-04-21T16:08:20Z")

</div>

I see my mistake, I am setting the opcItemPath on the UDT and not the proper tag. It should be on the Value tag, as that is where the opcItemPath is.

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

```python
path = '[014Edge]Beaverton/Case01/CleanModeSts/Value'
system.tag.writeBlocking(path+'.OPCItemPath','ns=1;s=[014-RACKA]hmi_sys_CleaningModeSts_nt[1]')
print(system.tag.readBlocking(path+'.opcItemPath')[0].value)

```

> [Good]  
> ns=1;s=[014-RACKA]hmi\_sys\_CleaningModeSts\_nt[1]

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

Unfortunately that still doesn't seem to achieve what I am going for

---

<div class="post-metadata">

**Author:** ![Everett\_Cass](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/everett_cass/32/86983_2.png) [@Everett\_Cass](https://forum.inductiveautomation.com/u/Everett_Cass)\
**Post date:** [April 21, 2025, 4:09pm UTC](https://forum.inductiveautomation.com/t/how-to-change-opcitempaths-using-scripting-on-udts-that-have-a-binding-that-uses-parameters/105184/9 "2025-04-21T16:09:31Z")

</div>

I was afraid of this, I will see if I can make some sort of function to be able to do this with ease, as using system.tag.configure is a bit more complicated than writeBlocking. I will update this post if I can come up with a clean function to make it simple

---

<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 21, 2025, 4:10pm UTC](https://forum.inductiveautomation.com/t/how-to-change-opcitempaths-using-scripting-on-udts-that-have-a-binding-that-uses-parameters/105184/10 "2025-04-21T16:10:34Z")

</div>

I would expect `writeBlocking()` to work. Note the mis-targeting diagnosed by Nick above.

---

<div class="post-metadata">

**Author:** ![Everett\_Cass](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/everett_cass/32/86983_2.png) [@Everett\_Cass](https://forum.inductiveautomation.com/u/Everett_Cass)\
**Post date:** [April 21, 2025, 4:15pm UTC](https://forum.inductiveautomation.com/t/how-to-change-opcitempaths-using-scripting-on-udts-that-have-a-binding-that-uses-parameters/105184/11 "2025-04-21T16:15:01Z")

</div>

You are correct, I was looking at the wrong tag provider. It appears my path was just wrong
