# Write OPC item path to custom property in UDT Instance

**URL:** <https://forum.inductiveautomation.com/t/write-opc-item-path-to-custom-property-in-udt-instance/69513>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [February 7, 2023, 6:21am UTC](https://forum.inductiveautomation.com/t/write-opc-item-path-to-custom-property-in-udt-instance/69513 "2023-02-07T06:21:04Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [February 7, 2023, 6:21am UTC](https://forum.inductiveautomation.com/t/write-opc-item-path-to-custom-property-in-udt-instance/69513/1 "2023-02-07T06:21:04Z")

</div>

Hi,  
I have UDT tags in different folders. I have created a custom property in UDT definition - called getOPCPath

i need to write a function to get the opc path of corresponding udt instance tag and write it to the custom property.

Why i am doing this because i am using MQQT so it's not fetching the OPC item path. so i am creating custom property and though that i am planing to fetch the OPC item path for all tags

this is the code i have used

```auto
parentPath = "[default]test_path"
 
# Get the current configurations recursivly, which is useful when targeting
# folders and UDT Instances
configs = system.tag.getConfiguration(parentPath, True)
print configs
# The getConfiguration() above always returns a list of dictionaries, and our results
# are inside of the first dictionary.
for tag in configs[0]['tags']:
 	print tag

```

it fetching all the udt tags in dictionary **i don't know i how to Manipulate to each tag in dictionary and get their OPC item path** and write it to same tag custom property

**custom property i have created in each tag** - **GetOpcPath** (its also there in dictionary )

```auto
[{u'tags': [{u'tags': [{u'tagGroup': u'2sec', u'tags': [{u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'expression': u'', u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kWhTON, u'opcItemPath': u'OPC_Path3', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'name': u'Consumption_kWhTON', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kWhTON', u'valueSource': u'opc', u'historyMaxAge': 5}, {u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'sampleMode': OnChange, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kW, u'opcItemPath': u'OPC_Path1', u'historyTagGroup': u'20sec', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'engHigh': 10.0, u'name': u'Consumption_kW', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kW', u'valueSource': u'opc', u'historyMaxAge': 5}, {u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'sampleMode': OnChange, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kWh, u'opcItemPath': u'OPC_Path2', u'historyTagGroup': u'20sec', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'name': u'Consumption_kWh', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kWh', u'valueSource': u'opc', u'historyMaxAge': 5}], u'path': Consumption, u'tagType': UdtInstance, u'name': u'Consumption', u'typeId': u'PFRCG12/Electric_v1', u'parameters': {u'OPC Server': {datatype=String, value=EMS PLC}, u'Database': {datatype=String, value=CHA_OT_Historian}}}], u'path': gas, u'tagType': Folder, u'name': u'gas'}, {u'tags': [{u'tags': [{u'tags': [{u'tagGroup': u'2sec', u'tags': [{u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'expression': u'', u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kWhTON, u'opcItemPath': u'water_Path3', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'name': u'Consumption_kWhTON', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kWhTON', u'valueSource': u'opc', u'historyMaxAge': 5}, {u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'sampleMode': OnChange, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kW, u'opcItemPath': u'water_Path1', u'historyTagGroup': u'20sec', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'engHigh': 10.0, u'name': u'Consumption_kW', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kW', u'valueSource': u'opc', u'historyMaxAge': 5}, {u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'sampleMode': OnChange, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kWh, u'opcItemPath': u'water_Path2', u'historyTagGroup': u'20sec', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'name': u'Consumption_kWh', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kWh', u'valueSource': u'opc', u'historyMaxAge': 5}], u'path': Consumption, u'tagType': UdtInstance, u'name': u'Consumption', u'typeId': u'PFRCG12/Electric_v1', u'parameters': {u'OPC Server': {datatype=String, value=EMS PLC}, u'Database': {datatype=String, value=CHA_OT_Historian}}}], u'path': water, u'tagType': Folder, u'name': u'water'}, {u'tagGroup': u'2sec', u'tags': [{u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'sampleMode': OnChange, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kWh, u'opcItemPath': u'comp_Path2', u'historyTagGroup': u'20sec', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'name': u'Consumption_kWh', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kWh', u'valueSource': u'opc', u'historyMaxAge': 5}, {u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'expression': u'', u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kWhTON, u'opcItemPath': u'comp_Path3', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'name': u'Consumption_kWhTON', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kWhTON', u'valueSource': u'opc', u'historyMaxAge': 5}, {u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'sampleMode': OnChange, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kW, u'opcItemPath': u'comp_Path1', u'historyTagGroup': u'20sec', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'engHigh': 10.0, u'name': u'Consumption_kW', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kW', u'valueSource': u'opc', u'historyMaxAge': 5}], u'path': Consumption, u'tagType': UdtInstance, u'name': u'Consumption', u'typeId': u'PFRCG12/Electric_v1', u'parameters': {u'OPC Server': {datatype=String, value=EMS PLC}, u'Database': {datatype=String, value=CHA_OT_Historian}}}], u'path': compressor, u'tagType': Folder, u'name': u'compressor'}, {u'tags': [{u'tagGroup': u'2sec', u'tags': [{u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'expression': u'', u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kWhTON, u'opcItemPath': u'temp_Path3', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'name': u'Consumption_kWhTON', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kWhTON', u'valueSource': u'opc', u'historyMaxAge': 5}, {u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'sampleMode': OnChange, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kWh, u'opcItemPath': u'temp_Path2', u'historyTagGroup': u'20sec', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'name': u'Consumption_kWh', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kWh', u'valueSource': u'opc', u'historyMaxAge': 5}, {u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'sampleMode': OnChange, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kW, u'opcItemPath': u'temp_Path1', u'historyTagGroup': u'20sec', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'engHigh': 10.0, u'name': u'Consumption_kW', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kW', u'valueSource': u'opc', u'historyMaxAge': 5}], u'path': Consumption, u'tagType': UdtInstance, u'name': u'Consumption', u'typeId': u'PFRCG12/Electric_v1', u'parameters': {u'OPC Server': {datatype=String, value=EMS PLC}, u'Database': {datatype=String, value=CHA_OT_Historian}}}], u'path': temp, u'tagType': Folder, u'name': u'temp'}], u'path': Electric, u'tagType': Folder, u'name': u'Electric'}], u'path': [default]test_path, u'tagType': Folder, u'name': u'test_path'}]
{u'tags': [{u'tagGroup': u'2sec', u'tags': [{u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'expression': u'', u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kWhTON, u'opcItemPath': u'OPC_Path3', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'name': u'Consumption_kWhTON', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kWhTON', u'valueSource': u'opc', u'historyMaxAge': 5}, {u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'sampleMode': OnChange, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kW, u'opcItemPath': u'OPC_Path1', u'historyTagGroup': u'20sec', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'engHigh': 10.0, u'name': u'Consumption_kW', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kW', u'valueSource': u'opc', u'historyMaxAge': 5}, {u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'sampleMode': OnChange, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kWh, u'opcItemPath': u'OPC_Path2', u'historyTagGroup': u'20sec', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'name': u'Consumption_kWh', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kWh', u'valueSource': u'opc', u'historyMaxAge': 5}], u'path': Consumption, u'tagType': UdtInstance, u'name': u'Consumption', u'typeId': u'PFRCG12/Electric_v1', u'parameters': {u'OPC Server': {datatype=String, value=EMS PLC}, u'Database': {datatype=String, value=CHA_OT_Historian}}}], u'path': gas, u'tagType': Folder, u'name': u'gas'}
{u'tags': [{u'tags': [{u'tags': [{u'tagGroup': u'2sec', u'tags': [{u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'expression': u'', u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kWhTON, u'opcItemPath': u'water_Path3', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'name': u'Consumption_kWhTON', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kWhTON', u'valueSource': u'opc', u'historyMaxAge': 5}, {u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'sampleMode': OnChange, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kW, u'opcItemPath': u'water_Path1', u'historyTagGroup': u'20sec', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'engHigh': 10.0, u'name': u'Consumption_kW', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kW', u'valueSource': u'opc', u'historyMaxAge': 5}, {u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'sampleMode': OnChange, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kWh, u'opcItemPath': u'water_Path2', u'historyTagGroup': u'20sec', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'name': u'Consumption_kWh', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kWh', u'valueSource': u'opc', u'historyMaxAge': 5}], u'path': Consumption, u'tagType': UdtInstance, u'name': u'Consumption', u'typeId': u'PFRCG12/Electric_v1', u'parameters': {u'OPC Server': {datatype=String, value=EMS PLC}, u'Database': {datatype=String, value=CHA_OT_Historian}}}], u'path': water, u'tagType': Folder, u'name': u'water'}, {u'tagGroup': u'2sec', u'tags': [{u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'sampleMode': OnChange, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kWh, u'opcItemPath': u'comp_Path2', u'historyTagGroup': u'20sec', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'name': u'Consumption_kWh', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kWh', u'valueSource': u'opc', u'historyMaxAge': 5}, {u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'expression': u'', u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kWhTON, u'opcItemPath': u'comp_Path3', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'name': u'Consumption_kWhTON', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kWhTON', u'valueSource': u'opc', u'historyMaxAge': 5}, {u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'sampleMode': OnChange, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kW, u'opcItemPath': u'comp_Path1', u'historyTagGroup': u'20sec', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'engHigh': 10.0, u'name': u'Consumption_kW', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kW', u'valueSource': u'opc', u'historyMaxAge': 5}], u'path': Consumption, u'tagType': UdtInstance, u'name': u'Consumption', u'typeId': u'PFRCG12/Electric_v1', u'parameters': {u'OPC Server': {datatype=String, value=EMS PLC}, u'Database': {datatype=String, value=CHA_OT_Historian}}}], u'path': compressor, u'tagType': Folder, u'name': u'compressor'}, {u'tags': [{u'tagGroup': u'2sec', u'tags': [{u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'expression': u'', u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kWhTON, u'opcItemPath': u'temp_Path3', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'name': u'Consumption_kWhTON', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kWhTON', u'valueSource': u'opc', u'historyMaxAge': 5}, {u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'sampleMode': OnChange, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kWh, u'opcItemPath': u'temp_Path2', u'historyTagGroup': u'20sec', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'name': u'Consumption_kWh', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kWh', u'valueSource': u'opc', u'historyMaxAge': 5}, {u'tagGroup': u'2sec', u'historyEnabled': True, u'historicalDeadband': 0.0, u'dataType': Float4, u'historicalDeadbandStyle': Discrete, u'sampleMode': OnChange, u'historyProvider': {bindType=parameter, binding={Database}}, u'path': Consumption_kW, u'opcItemPath': u'temp_Path1', u'historyTagGroup': u'20sec', u'historyMaxAgeUnits': MIN, u'tagType': AtomicTag, u'engHigh': 10.0, u'name': u'Consumption_kW', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'GetOpcPath': u'', u'engUnit': u'kW', u'valueSource': u'opc', u'historyMaxAge': 5}], u'path': Consumption, u'tagType': UdtInstance, u'name': u'Consumption', u'typeId': u'PFRCG12/Electric_v1', u'parameters': {u'OPC Server': {datatype=String, value=EMS PLC}, u'Database': {datatype=String, value=CHA_OT_Historian}}}], u'path': temp, u'tagType': Folder, u'name': u'temp'}], u'path': Electric, u'tagType': Folder, u'name': u'Electric'}

```

can any help me on this please

Attached sample tags for your reference  
[OPCPath\_test.json](https://forum.inductiveautomation.com/uploads/short-url/jgMpliitkLIxEwUvy51fhkJvAHl.json) (3.3 KB)

---

<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:** [February 7, 2023, 10:02am UTC](https://forum.inductiveautomation.com/t/write-opc-item-path-to-custom-property-in-udt-instance/69513/2 "2023-02-07T10:02:29Z")

</div>

GetConfiguration won't get you tag paths, it will get you the configuration of tags similar to the output you get from copying a tag's json. Have you tried using tag.browse? That will get you the tag paths (in the fullPath key for each result)

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [February 7, 2023, 10:07am UTC](https://forum.inductiveautomation.com/t/write-opc-item-path-to-custom-property-in-udt-instance/69513/3 "2023-02-07T10:07:46Z")

</div>

> [@prasath.t](#):
>
> `[0]['tags']`

Tag browse only browse the tag paths right?. using configuration we have able to right to the parameters right that's y i chosen this

---

<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:** [February 7, 2023, 10:38am UTC](https://forum.inductiveautomation.com/t/write-opc-item-path-to-custom-property-in-udt-instance/69513/4 "2023-02-07T10:38:56Z")

</div>

You can write to udt parameters using tag.write as well. Using getConfiguration with tag.configure to write to udt instances is dodgy if that's what you're doing, as getConfiguration get _all_ non-default values instead of just non-default values set in the UDT instance. Doing this will essentially decouple the UDT instance from its udt type.  
I believe you can use exportTags instead which gets you just the non-defaults of the UDT instance, as you would get using copy JSON

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [February 7, 2023, 10:43am UTC](https://forum.inductiveautomation.com/t/write-opc-item-path-to-custom-property-in-udt-instance/69513/5 "2023-02-07T10:43:07Z")

</div>

One thing is like i have around 600 tags  
i like to update all by running a function

If i export tags and manual edit it. it's difficult for me

if you have any idea do this. please give me any example script it will guide me  
@JordanCClark any idea from your end?

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [February 8, 2023, 7:01am UTC](https://forum.inductiveautomation.com/t/write-opc-item-path-to-custom-property-in-udt-instance/69513/6 "2023-02-08T07:01:04Z")

</div>

Hi @nminchin ,

as you said ,  
use system.tag.browse - to read all OPC tags  
then use system.tag.read to get OPC path  
then use system.tag,write - to write it custom property

it will be simple solution

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [February 8, 2023, 7:34am UTC](https://forum.inductiveautomation.com/t/write-opc-item-path-to-custom-property-in-udt-instance/69513/7 "2023-02-08T07:34:13Z")

</div>

For UDT's i can create custom property in UDT definition. it will reflect in all tags but  
**One doubt For OPc tags how to create custom property through scripting?**

```auto
tagConfig ={}
path = '[default]test 1/testing' # this is opc tag
tagConfig["GetOpcPath"] = "OPC_path1" # cusotm property i am trying to create
system.tag.configure(path, [tagConfig], "a")

```

---

<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:** [February 8, 2023, 9:50am UTC](https://forum.inductiveautomation.com/t/write-opc-item-path-to-custom-property-in-udt-instance/69513/8 "2023-02-08T09:50:02Z")

</div>

Do you mean a custom property on a tag? or UDT definition parameters?

For UDT parameters, if you look at a UDT definition's JSON, you'll find your answer.

```auto
{
   "name:" "asdasd",
   "parameters": {
      "Param1": {
         "dataType": "String",
         "value": "Val1"
      }
   }
   ...
}

```

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [February 8, 2023, 9:51am UTC](https://forum.inductiveautomation.com/t/write-opc-item-path-to-custom-property-in-udt-instance/69513/9 "2023-02-08T09:51:51Z")

</div>

custom property on tag

---

<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:** [February 8, 2023, 10:02am UTC](https://forum.inductiveautomation.com/t/write-opc-item-path-to-custom-property-in-udt-instance/69513/10 "2023-02-08T10:02:26Z")

</div>

You have to use something like this:

```auto
system.tag.configure(basepath='[default]test 1', tags=[
   {'tags': 
      [
         {'name': 'testing', 'GetOpcPath': 'OPC_path1'}
      ]
   }
]

```

However, this will replace the tag's configuration with exactly that, removing all other configuration. You either need to use getConfiguration or exportTags to get the existing configuration, then add the GetOpcPath key to that, if you want to keep the existing configuration. I actually thought there was an option to update configuration, but there doesn't seem to be...

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [February 8, 2023, 12:44pm UTC](https://forum.inductiveautomation.com/t/write-opc-item-path-to-custom-property-in-udt-instance/69513/11 "2023-02-08T12:44:09Z")

</div>

> [@nminchin](#):
>
> ```auto
> system.tag.configure(basepath='[default]test 1', tags=[
> {'tags': 
> [
> {'name': 'testing', 'GetOpcPath': 'OPC_path1'}
> ]
> }
> ]
> 
> ```

```auto
baseTagPath='[default]test'

tag = {'name': 'testing', 'GetOpcPath': 'OPC_path1'}
 
# Set the collision policy to Abort. Thus, if a tag already exists at the base path,
# we will not override the tag. If you are overwriting an existing tag, then set this to "o"
collisionPolicy = "m"
 
# Create the tag.
system.tag.configure(baseTagPath, [tag], collisionPolicy)

```

this script will only create custom property and doesn't remove other existing configuration  
**collisionPolicy = "m" (this is doing the trick)**

---

<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:** [February 8, 2023, 12:45pm UTC](https://forum.inductiveautomation.com/t/write-opc-item-path-to-custom-property-in-udt-instance/69513/12 "2023-02-08T12:45:52Z")

</div>

That's the one, I knew I'd seen it! It's not in the function's helper prompt though..

---

<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:** [February 8, 2023, 12:56pm UTC](https://forum.inductiveautomation.com/t/write-opc-item-path-to-custom-property-in-udt-instance/69513/13 "2023-02-08T12:56:51Z")

</div>

I have to admit I don't understand the point of this exercise. opcItemPath is a tag property. You are trying to copy these values to another tag property (custom) on the **same** tag. Why can your application **not** just use the normal tag property?

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [February 8, 2023, 1:00pm UTC](https://forum.inductiveautomation.com/t/write-opc-item-path-to-custom-property-in-udt-instance/69513/14 "2023-02-08T13:00:42Z")

</div>

Tag are in plant server ignition. I am pushing the tags from plant server ignition to Data centre side ignition through MQQT. MQQT doesn't pass the OPC path details to DC side. That's why i am doing like this

I hope you understood now

---

<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:** [February 8, 2023, 1:03pm UTC](https://forum.inductiveautomation.com/t/write-opc-item-path-to-custom-property-in-udt-instance/69513/15 "2023-02-08T13:03:39Z")

</div>

Ah, so not the **same** tag, but the tag or reference tag as it appears on the MQTT receiving end. Yes, this makes sense.
