# Modify UDT member tag with system.tag.configure

**URL:** <https://forum.inductiveautomation.com/t/modify-udt-member-tag-with-system-tag-configure/32311>\
**Category:** Ignition\
**Created:** [February 16, 2020, 8:16am UTC](https://forum.inductiveautomation.com/t/modify-udt-member-tag-with-system-tag-configure/32311 "2020-02-16T08:16:33Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![nader.chinichian](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nader.chinichian/32/9261_2.png) [@nader.chinichian](https://forum.inductiveautomation.com/u/nader.chinichian)\
**Post date:** [February 16, 2020, 8:16am UTC](https://forum.inductiveautomation.com/t/modify-udt-member-tag-with-system-tag-configure/32311/1 "2020-02-16T08:16:33Z")

</div>

Hi

I want to modify the members of UDT tag with system.tag.configure. For example OpcItemPath.  
Can someone help me on that.  
The old system.tag.write(tagFolder + tag + ‘.OPCItemPath’,OPCItemPath) doesn’t work anymore.

Thanks.

---

<div class="post-metadata">

**Author:** ![tordvd](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tordvd/32/11525_2.png) [@tordvd](https://forum.inductiveautomation.com/u/tordvd)\
**Post date:** [February 16, 2020, 11:28am UTC](https://forum.inductiveautomation.com/t/modify-udt-member-tag-with-system-tag-configure/32311/2 "2020-02-16T11:28:15Z")

</div>

this is for changing parameters within a UDT, but it should be the same:

```auto
def updateParameterValue(path,paramName,newValue):
	import system
	# Get current configurations
	tagPath=str(path)
	print tagPath
	tags = system.tag.getConfiguration(tagPath)
	empty=[]
	for tagDict in tags:
		# Iterate over the dictionary with the iteritems function
		for key, value in tagDict.iteritems():
			# Do something with the keys and values
			#print key, ' : ', value
			empty=[]
	tag1=tags[0]
	tag1['parameters'][paramName]=newValue
	tagList=[tag1]
	
	collisionPolicy = "o"
	baseTagPath=tagPath.rsplit("/",1)[0]
	print "Writing data to: %s, Parameter: %s, New value : %s" % (path,paramName, newValue)
	system.tag.configure(baseTagPath, tagList, collisionPolicy)
	print "Tag updated!"

```

---

<div class="post-metadata">

**Author:** ![nader.chinichian](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nader.chinichian/32/9261_2.png) [@nader.chinichian](https://forum.inductiveautomation.com/u/nader.chinichian)\
**Post date:** [February 20, 2020, 6:42am UTC](https://forum.inductiveautomation.com/t/modify-udt-member-tag-with-system-tag-configure/32311/3 "2020-02-20T06:42:03Z")

</div>

Thanks but is there any easier way to access opcItemPath?  
I dont get the members.  
When I try to access member with system.tag.configure i get invalid tagpath error.  
So I wonder how change member attribute with system.tag.configure().

```auto
tagName = "PI05051/PV"
opcItemPath = "ns=1;s=[Simulator]_Meta:Sine/Sine0"
opcServer = "Ignition OPC-UA Server"
valueSource = "opc"
 
# Configure the tag.
tag = {
            "name": tagName,           
            "opcItemPath" : opcItemPath,
            "opcServer": opcServer,
            "valueSource": valueSource,
        }
 
# Create the tag.
print system.tag.configure('DPB', [tag], 'm')

```

---

<div class="post-metadata">

**Author:** ![tordvd](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tordvd/32/11525_2.png) [@tordvd](https://forum.inductiveautomation.com/u/tordvd)\
**Post date:** [February 20, 2020, 9:10am UTC](https://forum.inductiveautomation.com/t/modify-udt-member-tag-with-system-tag-configure/32311/4 "2020-02-20T09:10:52Z")

</div>

Dont know of any easier way, but i just tried this, and it worked:

```auto
def updateOPCPath(path,newOpcPath):
	import system
	# Get current configurations
	tagPath=str(path)
	tags = system.tag.getConfiguration(tagPath)
	empty=[]
	for tagDict in tags:
		# Iterate over the dictionary with the iteritems function
		for key, value in tagDict.iteritems():
			# Do something with the keys and values
			#print key, ' : ', value
			empty=[]
	tag1=tags[0]
	
	tag1['opcItemPath']=newOpcPath
	tagList=[tag1]
	
	collisionPolicy = "o"
	baseTagPath=tagPath.rsplit("/",1)[0]
	system.tag.configure(baseTagPath, tagList, collisionPolicy)
	print "Tag updated!"
updateOPCPath(tagpath,newOpcPath)
tagpath="[Remote_Ignition_DataServer]temp/myOPCTag"
newOpcPath="ns=1;s=[Simulated_Device]_Meta:Ramp/Ramp2"

```

---

<div class="post-metadata">

**Author:** ![nader.chinichian](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nader.chinichian/32/9261_2.png) [@nader.chinichian](https://forum.inductiveautomation.com/u/nader.chinichian)\
**Post date:** [February 22, 2020, 9:12am UTC](https://forum.inductiveautomation.com/t/modify-udt-member-tag-with-system-tag-configure/32311/5 "2020-02-22T09:12:27Z")

</div>

> [@tordvd](#):
>
> iteritems

Ok my problem is if you have a UDT with several folder in it, the `tag1['opcItemPath']=newOpcPath` doesn't go to the deepest level I want.

Area1/PI053401/ALARM/Setpoint/HighSetpoint  
Area1 = folder  
PI053401 = UDT instance = main tag  
/ALARM/Setpoint/ = folder structure in UDT  
HighSetpoint = Atomic Tag in UDT

So how I can go to HighSetpoint.opcItemPath?  
Your code only access to first level opcItemPath, if the tag is normal and NOT UDT.

---

<div class="post-metadata">

**Author:** ![tordvd](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tordvd/32/11525_2.png) [@tordvd](https://forum.inductiveautomation.com/u/tordvd)\
**Post date:** [February 24, 2020, 2:12pm UTC](https://forum.inductiveautomation.com/t/modify-udt-member-tag-with-system-tag-configure/32311/6 "2020-02-24T14:12:33Z")

</div>

I think i understand.

This one works for members of UDT’s. It is a bit crude/hard coded, and you need to find the index of the tag within that UDT. But it might get you started.

The main issue i get here, is that all tags within the UDT get overwritten. Even though i dont change them. Maybe you will find out why…

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

```auto

import system
path="[Remote_Ignition_DataServer]temp/UDT1"
baseTagPath="[Remote_Ignition_DataServer]temp"

# Get current configurations
tagList = system.tag.getConfiguration(tagPath,True)
tagDict=tagList[0]

tagDict["tags"][0]["opcItemPath"]=u"ns=1;s=[Simulated_Device]_Meta:Ramp/Ramp2"
tagDict["tags"][1]["opcItemPath"]=u"ns=1;s=[Simulated_Device]_Meta:Ramp/Ramp3"
tagListNew=[tagDict]

collisionPolicy = "m"

print baseTagPath
system.tag.configure(baseTagPath, tagListNew, collisionPolicy)
print "Tag updated!"

```

---

<div class="post-metadata">

**Author:** ![nader.chinichian](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nader.chinichian/32/9261_2.png) [@nader.chinichian](https://forum.inductiveautomation.com/u/nader.chinichian)\
**Post date:** [February 25, 2020, 7:36am UTC](https://forum.inductiveautomation.com/t/modify-udt-member-tag-with-system-tag-configure/32311/7 "2020-02-25T07:36:49Z")

</div>

Thanks. but I in your code you assume that you know the UDT structure. If you have a dynamic path how do you create the structure?  
Imagine this  
Path = Area1/CompB/…/SectionB/Temp/PV  
in this example you don’t know how many deep level you have and is each level is folder or another UDT.  
in v7.9 I simply pass Path to system.tag.write like this:  
system.tag.write(Path + “.opcItemPath”, “ns=1;s=[Simulated\_Device]\_Meta:Ramp/Ramp2”)  
but in v8 it doesn’t work.  
Do you know any workaround for this?

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [February 25, 2020, 3:38pm UTC](https://forum.inductiveautomation.com/t/modify-udt-member-tag-with-system-tag-configure/32311/8 "2020-02-25T15:38:21Z")

</div>

The [solution I gave in the other post](http://forum.inductiveautomation.com/t/overriding-properties-in-udt-instances-by-system-tag-writeasync/32516/20?u=witman) is more complex to deal with the request to build the structure for any nesting level from the same base path. Here’s a simple direct system.tag.configure replacement for the tag write to tag property that you have above:

```python
def overrideTagProperty(path, value):
	basePath, name, overrideProperty = path.replace('.','/').rsplit('/', 2)
	system.tag.configure(basePath, [{'name':name, overrideProperty:value}], 'm')

overrideTagProperty(Path + ".opcItemPath", "ns=1;s=[Simulated_Device]_Meta:Ramp/Ramp2")

```

---

<div class="post-metadata">

**Author:** ![sistemas](https://avatars.discourse-cdn.com/v4/letter/s/858c86/32.png) [@sistemas](https://forum.inductiveautomation.com/u/sistemas)\
**Post date:** [February 26, 2020, 12:19pm UTC](https://forum.inductiveautomation.com/t/modify-udt-member-tag-with-system-tag-configure/32311/9 "2020-02-26T12:19:17Z")

</div>

I had the same problem @nader.chinichian. Just replace the system.tag.write(tag, value) function to system.tag.writeAsync([tag], [value]).

---

<div class="post-metadata">

**Author:** ![nader.chinichian](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nader.chinichian/32/9261_2.png) [@nader.chinichian](https://forum.inductiveautomation.com/u/nader.chinichian)\
**Post date:** [February 27, 2020, 6:20am UTC](https://forum.inductiveautomation.com/t/modify-udt-member-tag-with-system-tag-configure/32311/10 "2020-02-27T06:20:15Z")

</div>

It doesn’t work if the property inherent from udt parent. Because if see json of the tag that property doesn’t include and so system.tag.writeasync doesn’t work.
