# System.tag.configure incorrectly overriding multiple UDT tag properties

**URL:** <https://forum.inductiveautomation.com/t/system-tag-configure-incorrectly-overriding-multiple-udt-tag-properties/40593>\
**Category:** Ignition\
**Created:** [November 12, 2020, 5:37pm UTC](https://forum.inductiveautomation.com/t/system-tag-configure-incorrectly-overriding-multiple-udt-tag-properties/40593 "2020-11-12T17:37:17Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![mpaulson745](https://avatars.discourse-cdn.com/v4/letter/m/fbc32d/32.png) [@mpaulson745](https://forum.inductiveautomation.com/u/mpaulson745)\
**Post date:** [November 12, 2020, 5:37pm UTC](https://forum.inductiveautomation.com/t/system-tag-configure-incorrectly-overriding-multiple-udt-tag-properties/40593/1 "2020-11-12T17:37:17Z")

</div>

I need a quick way to programmatically override properties on certain tags inside a UDT. For instance, setting a custom description for multiple iterations of the same device. The solution I’ve come up with is to read the tag configuration using system.tag.getConfiguration and then search through the result and modify the ‘value’ property for the tag in question. Then I pass the modified configuration back into system.tag.configure. I’m able to successfully change the value I want, however, it seems that when I write the modified configuration, other properties on the tag are showing as overridden. The values still match the UDT definition but it doesn’t seem like this is right. Appreciate any ideas on how to prevent unintentionally overriding extra tag properties.

Simplified version of my script (I just hardcoded the property modification to keep the post shorter)

```auto
folder = "[default]CP1/Test Folder"
updateTagName = 'UDT Tester'
nodes = system.tag.getConfiguration(folder + '/' + updateTagName, True)

nodes[0]["tags"][0]["tags"][1]["value"] = "Divert 1"
system.tag.configure(folder,nodes)

```

Multiple properties show as overridden even though I’m only changing the Value property

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/1/41ffdc90f5fc40eab2826d2b7dedc5c56cf15552.png)

---

<div class="post-metadata">

**Author:** ![levi\_jacobs](https://avatars.discourse-cdn.com/v4/letter/l/ba9def/32.png) [@levi\_jacobs](https://forum.inductiveautomation.com/u/levi_jacobs)\
**Post date:** [April 29, 2021, 2:46pm UTC](https://forum.inductiveautomation.com/t/system-tag-configure-incorrectly-overriding-multiple-udt-tag-properties/40593/2 "2021-04-29T14:46:06Z")

</div>

I’m also seeing this happen in 8.3.1

---

<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:** [May 17, 2021, 12:43am UTC](https://forum.inductiveautomation.com/t/system-tag-configure-incorrectly-overriding-multiple-udt-tag-properties/40593/3 "2021-05-17T00:43:09Z")

</div>

> [@levi\_jacobs](#):
>
> 8.3.1

Where can I download this version from? I'm sure IA would be interested to know as well! 😆

> [@mpaulson745](#):
>
> Multiple properties show as overridden even though I’m only changing the Value property

I have seen this happen as well in later versions possibly even as late as 8.1.5 although I can't be sure.. I noticed it recently when I found a UDT's tags had unexpectedly different config from the definition; I can't remember exactly, but from memory the data type didn't match. Then I noticed that the UDT instance config was overridden which I thought was strange as I wouldn't normally do that.  
Good to know, and certainly seems like a bug!

@paul-griffith

---

<div class="post-metadata">

**Author:** ![levi\_jacobs](https://avatars.discourse-cdn.com/v4/letter/l/ba9def/32.png) [@levi\_jacobs](https://forum.inductiveautomation.com/u/levi_jacobs)\
**Post date:** [May 24, 2021, 3:19pm UTC](https://forum.inductiveautomation.com/t/system-tag-configure-incorrectly-overriding-multiple-udt-tag-properties/40593/4 "2021-05-24T15:19:37Z")

</div>

Haha… 8.1.3 🤦‍♂️

---

<div class="post-metadata">

**Author:** ![kyle.demerath](https://avatars.discourse-cdn.com/v4/letter/k/5e9695/32.png) [@kyle.demerath](https://forum.inductiveautomation.com/u/kyle.demerath)\
**Post date:** [October 6, 2021, 6:11pm UTC](https://forum.inductiveautomation.com/t/system-tag-configure-incorrectly-overriding-multiple-udt-tag-properties/40593/5 "2021-10-06T18:11:42Z")

</div>

I have seen this same issue too still in 8.1.9. It would be nice to see this fixed as I assume that once it is flagged as overridden it will no longer update if you change the parent UDT.

---

<div class="post-metadata">

**Author:** ![richardNZ15](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/richardnz15/32/33373_2.png) [@richardNZ15](https://forum.inductiveautomation.com/u/richardNZ15)\
**Post date:** [January 13, 2022, 9:07pm UTC](https://forum.inductiveautomation.com/t/system-tag-configure-incorrectly-overriding-multiple-udt-tag-properties/40593/6 "2022-01-13T21:07:58Z")

</div>

I am still seeing this problem in 8.1.13…  
This is a pretty bad bug in my mind as we can’t reliably configure tags to update just one property, without potentially screwing over an entire UDT.  
For instance in my UDT i have three expression tags. I want to simply change the expression so that it overrides what the parent UDT has by default. But in doing so, i am getting all sorts of unrelated properties being overridden.

```auto
rootPath = "[default]_types_/Basic/Real"
configs = system.tag.getConfiguration(rootPath, True)
###print configs[0]["tags"]
for tag in configs[0]["tags"]:
	###print tag['name']
	if tag['name'] == 'Active':
		print tag['name']
		print tag['expression']
		# Set new expression
		tag['expression'] = "{[.]Value/Alarms.HasActive}"
		
# end for

# Write changes to config definition back to UDT definition
print system.tag.configure(rootPath,configs[0]["tags"],"m")

```

This yields the following results where not only the “Expression” has been overridden, but so has all sorts of other properties for the tag “Active”.

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

---

<div class="post-metadata">

**Author:** ![swolnisty](https://avatars.discourse-cdn.com/v4/letter/s/7bcc69/32.png) [@swolnisty](https://forum.inductiveautomation.com/u/swolnisty)\
**Post date:** [January 13, 2022, 9:21pm UTC](https://forum.inductiveautomation.com/t/system-tag-configure-incorrectly-overriding-multiple-udt-tag-properties/40593/7 "2022-01-13T21:21:24Z")

</div>

As a workaround, you could ONLY programmatically update the properties that you are changing (or have already been overridden with a value different than what is configured on the UDT definition itself). This is what I typically do:

```auto
tagPath = '[default]some/path/to/udt/tag'
parentPath = str(tagPath).rsplit('/',1)[0]
tagConfig = dict(system.tag.getConfiguration(tagPath, True)[0])
udtPath = '[default]_types_/path/to/udt/tag'
udtConfig = dict(system.tag.getConfiguration(udtPath, True)[0])
del tagConfig['path']	# Tags seem to break if you accidentally write back to the path property
for key in tagConfig:
	if tagConfig[key] == udtConfig.get(key, '') and str(key) != 'name':
		del tagConfig[key]
tagConfig['propertyToBeUpdated'] = 'newPropertyValue'
system.tag.configure(parentPath, tagConfig, "o")

```

It’s not the ideal solution, but it gets the job done for me.

---

<div class="post-metadata">

**Author:** ![richardNZ15](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/richardnz15/32/33373_2.png) [@richardNZ15](https://forum.inductiveautomation.com/u/richardNZ15)\
**Post date:** [January 13, 2022, 9:57pm UTC](https://forum.inductiveautomation.com/t/system-tag-configure-incorrectly-overriding-multiple-udt-tag-properties/40593/8 "2022-01-13T21:57:53Z")

</div>

Interesting… thanks i’ll have a play.  
So this is actually configuring a UDT **instance** right?  
Currently i’m trying to configure the UDT itself but i will also need to do this at some point soon.

Are you effectively just stripping out all tagConfig keys except the ‘name’?

---

<div class="post-metadata">

**Author:** ![swolnisty](https://avatars.discourse-cdn.com/v4/letter/s/7bcc69/32.png) [@swolnisty](https://forum.inductiveautomation.com/u/swolnisty)\
**Post date:** [January 13, 2022, 10:05pm UTC](https://forum.inductiveautomation.com/t/system-tag-configure-incorrectly-overriding-multiple-udt-tag-properties/40593/9 "2022-01-13T22:05:44Z")

</div>

Yes, in my example post I was assuming that ‘some’ would be an instance of UDT ‘path’ and ‘to/udt/tag’ would be a folder structure within the UDT where ‘tag’ is the actual tag being configured. This example should still apply if you were modifying a UDT with another parent UDT. the tagPath property in the above example would just be something like ‘[default]_types_/childUDT/tag’ while udtPath would be something like ‘[default]_types_/parentUDT/tag’

And yes, I am effectively stripping out all the keys of the tag configuration besides ‘name’ (which is needed to determine which tag is being configured), the key of the property you wanted to update, and any other tag properties whose values differ from the parent UDT’s. If you wanted to revert the child UDT back to the parent UDT’s tag properties entirely, your tagConfig would only consist of the name property.

---

<div class="post-metadata">

**Author:** ![richardNZ15](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/richardnz15/32/33373_2.png) [@richardNZ15](https://forum.inductiveautomation.com/u/richardNZ15)\
**Post date:** [January 13, 2022, 10:07pm UTC](https://forum.inductiveautomation.com/t/system-tag-configure-incorrectly-overriding-multiple-udt-tag-properties/40593/10 "2022-01-13T22:07:55Z")

</div>

I managed to achieve what i needed by defining only the expression tags i wanted in a totally separate array.

```auto
alarmTags = [  
	{
	  "expression": "some expression here",
	  "name": "Active",
	  "tagType": "AtomicTag"
	},
    {
      "expression": "some expression here",
      "name": "Acked",
      "tagType": "AtomicTag"
    },
    {
      "expression": "some expression here",
      "name": "Alarm",
      "tagType": "AtomicTag"
    },
    {
      "expression": "some expression here",
      "name": "AlarmPriority",
      "tagType": "AtomicTag"
    },
]

print system.tag.configure(rootPath,alarmTags,"m")	

```

Then using that in system.tag.config. That also seems to only override the destination tags that match, and not affect anything else in the UDT.

Maybe thats what IA intended us to do, but i’m still getting my head around this new JSON tag structure and the new config functionality.

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [June 5, 2022, 12:59am UTC](https://forum.inductiveautomation.com/t/system-tag-configure-incorrectly-overriding-multiple-udt-tag-properties/40593/11 "2022-06-05T00:59:26Z")

</div>

I am playing around with changing properties programmatically, most of which are instances of UDTs. If I change a tag property, something like this,

```auto
tagPath = 'myPath'
parentPath = str(tagPath).rsplit('/',1)[0]

props = [
            {
                'name': 'Tag1', 
            	'value': 111
            }
        ]
        
tags = [
			{
				"tags":props,
				"name":"New Instance"
			}
		]

print system.tag.configure(parentPath,tags,"m")

```

I only see the property `value` for Tag1 get set to override, which is what I want.

However, if I do something similar for alarms,

```auto
tagPath = 'myPath'
parentPath = str(tagPath).rsplit('/',1)[0]

alarms = [
            {
                'name': 'Alarm1', 
                "setpointA":10,
                "label":'i changed the label'
            }
        ]
        
tags = [
			{
				"alarms":alarms,
				"name":"Alm1"
			}
		]

print system.tag.configure(parentPath,tags,"m")

```

it sets the entire alarm to override. Is this normal? Fixable?

I’m using 8.1.17.

---

<div class="post-metadata">

**Author:** ![swolnisty](https://avatars.discourse-cdn.com/v4/letter/s/7bcc69/32.png) [@swolnisty](https://forum.inductiveautomation.com/u/swolnisty)\
**Post date:** [June 6, 2022, 4:25pm UTC](https://forum.inductiveautomation.com/t/system-tag-configure-incorrectly-overriding-multiple-udt-tag-properties/40593/12 "2022-06-06T16:25:51Z")

</div>

From what I have tested in 8.1.10 through 8.1.17, this is normal. Obnoxious, but normal.

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [June 6, 2022, 4:43pm UTC](https://forum.inductiveautomation.com/t/system-tag-configure-incorrectly-overriding-multiple-udt-tag-properties/40593/13 "2022-06-06T16:43:19Z")

</div>

And nothing really that we can do to side step the obnoxiousness? 🙂

---

<div class="post-metadata">

**Author:** ![swolnisty](https://avatars.discourse-cdn.com/v4/letter/s/7bcc69/32.png) [@swolnisty](https://forum.inductiveautomation.com/u/swolnisty)\
**Post date:** [June 6, 2022, 4:49pm UTC](https://forum.inductiveautomation.com/t/system-tag-configure-incorrectly-overriding-multiple-udt-tag-properties/40593/14 "2022-06-06T16:49:11Z")

</div>

Not that I have found. Maybe IA has some tricks up their sleeves though? @paul-griffith

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [June 6, 2022, 4:55pm UTC](https://forum.inductiveautomation.com/t/system-tag-configure-incorrectly-overriding-multiple-udt-tag-properties/40593/15 "2022-06-06T16:55:46Z")

</div>

Travis Cox responded on the side and told me this is the way until perhaps 8.2 when they go to storing tags in file system. Appreciate the clarification on 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:** [June 7, 2022, 11:24pm UTC](https://forum.inductiveautomation.com/t/system-tag-configure-incorrectly-overriding-multiple-udt-tag-properties/40593/16 "2022-06-07T23:24:33Z")

</div>

> [@jlandwerlen](#):
>
> storing tags in file system

Interesting. I wonder how this will be done? just a massive json file? :S I wonder how fast this will be especially for larger tag databases

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [June 7, 2022, 11:28pm UTC](https://forum.inductiveautomation.com/t/system-tag-configure-incorrectly-overriding-multiple-udt-tag-properties/40593/17 "2022-06-07T23:28:47Z")

</div>

Not sure. I’m not sure it will be implemented, but they seem to think it’s possible where as right now it isn’t.

---

<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:** [October 20, 2022, 4:38am UTC](https://forum.inductiveautomation.com/t/system-tag-configure-incorrectly-overriding-multiple-udt-tag-properties/40593/18 "2022-10-20T04:38:28Z")

</div>

FWIW, I recently forgot about this and inadvertently added property overrides to a large number of UDTInstance tags 😕 So I created a script to remove the prop overrides on tags part of UDT instances that were not included in a list of property names.

The script copies the tag json back into clipboard, so you can review it first before saving as a json and importing it back in.

> **Main Functions**
>
> ```auto
> def removePropOverrides(tags, retainProps=None, tagpath='', insideUDTInstance=False):
> '''
> This will remove property overrides set on tags that are within UDTInstances that are not
> contained within the predefined retain set, or the retain set passed into the function.
> 	
> Revision History
> ===========
> Rev	Date Author Comment
> 1.0	2022-10-20	Nick Minchin	Original
> 	
> 	
> Args
> ===========
> tags: - tag json e.g. copied into the clipboard by using the "Copy JSON" context menu option from the Tag Browser
> retainProps: - a set with a list of properties to retain, for example {'writePermissions'}
> tagpath: - INTERNAL USE ONLY. Keeps track of the relative tag path used to print the properties removed along with the tags they were removed from.
> insideUDTInstance:	- INTERNAL USE ONLY. Keeps track of whether or not the current `tags` are within a UDT instance or not. This will determine if tag props 
> will be removed or not.
> 						  
> Return
> ===========
> Returns the modified tags as a Py object of dicts and lists
> '''
> fn = 'removePropOverrides()'
> this = removePropOverrides
> if isinstance(tags, str) or isinstance(tags, unicode):
> tags = system.util.jsonDecode(tags)
> 	
> if retainProps is None:
> retainProps = {}
> if not isinstance(retainProps, set):
> retainProps = set(retainProps)
> 	
> # these props should always exist and should not be removed!
> retainProps.add('name')
> retainProps.add('tagType')
> retainProps.add('tags')
> retainProps.add('value')
> retainProps.add('parameters')
> retainProps.add('typeId')
> 	
> # remove all props not in the retain list, if the tag is within a UDTInstance
> if isinstance(tags, dict):
> if insideUDTInstance:
> removedKeys = []
> for key in tags:
> if key not in retainProps:
> removedKeys.append(key)
> del tags[key]
> 			
> if len(removedKeys) > 0:
> print 'Tag: "{}", Removed keys: {}'.format(tagpath, system.util.jsonEncode(removedKeys))
> 		
> # check if the tags object has child tags and run the function over these as well
> if 'tags' in tags:
> for tag in tags['tags']:
> insideUDTInstance_ = insideUDTInstance or 'typeId' in tag
> this(tag, retainProps, tagpath + '/' + tag['name'], insideUDTInstance_)
> return tags
> 
> def removePropOverridesFromClipboard(retainProps=None):
> '''
> This is a wrapper for removePropOverrides which passes in tag json stored in the clipboard.
> '''
> tag_json = shared.util.clipboard.readText()	
> tags = removePropOverrides(tag_json, retainProps)
> 	
> return tags
> 
> tags=removePropOverridesFromClipboard({'writePermissions'})
> shared.util.clipboard.writeText(system.util.jsonEncode(tags))
> 
> ```

> **Clipboard Functions**
>
> ```auto
> from java.awt.datatransfer import StringSelection
> from java.awt.datatransfer import Clipboard
> from java.awt import Toolkit 
> 
> def setup():
> global toolkit, clipboard
> 	
> toolkit = Toolkit.getDefaultToolkit()
> clipboard = toolkit.getSystemClipboard()	
> 
> def writeText(text):
> setup()
> clipboard.setContents(StringSelection(text), None)
> 	
> def readText():
> setup()
> from java.awt.datatransfer import DataFlavor
> contents = clipboard.getContents(None)
> return contents.getTransferData(DataFlavor.stringFlavor)
> 
> ```

For example, the output print statements will return something like below. If you don't get anything printed, then no tags are affected.

> **Example Print Statement Output**
>
> ```auto
> Tag: "/Folder 1/Instance/Sec", Removed keys: ["deadband","opcServer"]
> Tag: "/Folder 1/Instance/Month", Removed keys: ["deadband","opcServer"]
> Tag: "/Folder 1/Instance/Day", Removed keys: ["dataType","opcServer","valueSource"]
> Tag: "/Folder 1/Instance/Year", Removed keys: ["deadband","opcServer"]
> Tag: "/Folder 1/Folder 2/Instance/Day", Removed keys: ["dataType","opcServer","valueSource"]
> Tag: "/Folder 2/Instance/Day", Removed keys: ["dataType","opcServer","valueSource"]
> Tag: "/Folder 2/Folder 1/Instance/Month", Removed keys: ["deadband","opcServer"]
> Tag: "/Folder 2/Folder 1/Instance/Day", Removed keys: ["dataType","opcServer","valueSource"]
> Tag: "/Folder 2/Folder 1/Instance/Year", Removed keys: ["deadband","opcServer"]
> Tag: "/Folder 2/Folder 1/Instance/Sec", Removed keys: ["deadband","opcServer"]
> Tag: "/Folder 2/Folder 1/Folder 2/Instance/Day", Removed keys: ["dataType","opcServer","valueSource"]
> 
> ```

**And if not obvious, use at your own risk. Check the output before actually importing anything! (and take a backup of your tags in case you need to revert)**

---

<div class="post-metadata">

**Author:** ![Nathan\_Foster](https://avatars.discourse-cdn.com/v4/letter/n/ecd19e/32.png) [@Nathan\_Foster](https://forum.inductiveautomation.com/u/Nathan_Foster)\
**Post date:** [January 29, 2023, 9:34pm UTC](https://forum.inductiveautomation.com/t/system-tag-configure-incorrectly-overriding-multiple-udt-tag-properties/40593/19 "2023-01-29T21:34:03Z")

</div>

I was having the same issues when trying to update tag configurations for UDT instances. Below is my temporary fix. This is the same tag configuration JSON you would get by right clicking the tag and selecting "Copy JSON". I usually use the result from `getTagConfigObj()` to make changes to the configuration. Then convert it back to a JSON string with `system.util.jsonEncode()`. Finally, I use `system.tag.configure()` to update the UDT instance. Definitely not the most efficient solution since it requires reading/writing to IO, but works for me.

```auto
def getTagConfigStr(tagPath):
	filePath = system.file.getTempFile('.json')
	system.tag.exportTags(filePath, [tagPath])
	tagConfigStr = system.file.readFileAsString(filePath)
	
	return tagConfigStr

def getTagConfigObj(tagPath):
	return system.util.jsonDecode(getTagConfigStr(tagPath))	

```

Update: Thanks to FrankP, no IO required!

```auto
def getTagConfigStr(tagPath):
	return system.tag.exportTags(tagPaths = [tagPath])
	
def getTagConfigObj(tagPath):
	return system.util.jsonDecode(getTagConfigStr(tagPath))	

```

---

<div class="post-metadata">

**Author:** ![FrankP](https://avatars.discourse-cdn.com/v4/letter/f/34f0e0/32.png) [@FrankP](https://forum.inductiveautomation.com/u/FrankP)\
**Post date:** [January 31, 2023, 10:59pm UTC](https://forum.inductiveautomation.com/t/system-tag-configure-incorrectly-overriding-multiple-udt-tag-properties/40593/20 "2023-01-31T22:59:56Z")

</div>

Nathan,

From the manual, it looks like system.tag.exportTags will return a return a string as a tag export if the file path is omitted. Perhaps can use that with the jsonDecode and get the same result with less file IO? I might play with this later.

-Frank

[Next page](https://forum.inductiveautomation.com/t/system-tag-configure-incorrectly-overriding-multiple-udt-tag-properties/40593.md?page=2)
