Remove some tag's overrides

I would like to remove some tag’s overrides in order the tag properties come back to the udt definition.
Is it possible with system.tag.configure ? loke we can do with the tag editor with the small green/grey override balls.

If we provide a tag propertie to system.tag.configure this add an overrides, but I don’t find the synthax to remove this overrides ?

Removing an override is as simple as removing the key from the tag json dictionary.


basePath = '[default]Tag/Path'
tags = system.tag.getConfiguration(basePath=basePath,
# remove the history enabled override
system.tag.configure(basePath='/'.join(basePath.split('/')[:-1]), tags=tags)

Have you noticed that using this method of modifying a tag results in other tag properties showing as overridden even though they are not the intended target of the script? I’ve used the same method to override a tag and see strange results. See link to my previous post here. I’m on v8.0.5

How would you check for a specific tag? In this example you are removing the historyEnabled property override on the 0th tag in the config.
Is there a way to access a tag by its [‘name’] json property?
or do you have to loop through all the tags in [‘tags’] and find it manually, then do something then?

Yep. Because it’s in an array, you can’t find a tag by name directly as you would be able to if it was a dictionary with the key as the tag name. You have to loop through the array until you find it.

Right, so when i find the tag i want, i managed to “pop” the overridden property out of the JSON dict.
But when i try use that in the system.tag.configure again, i get that annoying bug where a bunch of other properties are now overridden that weren’t before.

I think this was addressed in another forum thread where someone said you had to strip out everything except for stuff you DO want overridden.
Do i need to go back to that method where you have to compare the original UDT config with the current tag instance config, and figure out what is different etc… etc… ?

In a lot of cases you just want to change a particular property, and leave the rest alone.
Its maddening how difficult that is at first glance.

For example:

tagPath = "[default]temp/testOverrides/IL23013"
# Set the override such that the "Out" child tag is set to readOnly = True
# Default for UDT is readOnly = False
overrides = [{"name":"Out", "readOnly":True}]
print system.tag.configure(tagPath,overrides,"m")	

# Try and remove that specific override ONLY..
tagConfig = system.tag.getConfiguration(basePath=tagPath + '/Out',recursive=False)

## NOTE: print tagConfig provides the following:
# The only actually overridden property is readOnly at this point... I've checked
[{u'tagGroup': u'Direct_Realtime', u'historyEnabled': True, u'engLow': -0.5, u'historicalDeadband': 0.1, u'dataType': Boolean, u'historicalDeadbandStyle': Discrete, u'tooltip': {bindType=parameter, binding={Description} Out Rqst}, u'sampleMode': TagGroup, u'writePermissions': {"type":"AllOf","securityLevels":[]}, u'readOnly': True, u'enabled': True, u'historyProvider': u'Splitter', u'path': [default]temp/testOverrides/IL23013/Out, u'readPermissions': {"type":"AllOf","securityLevels":[]}, u'opcItemPath': {bindType=parameter, binding=ns=1;s=[{Device}]{Tag Name}.Out}, u'historyTagGroup': u'Default Historical', u'historyMaxAgeUnits': HOUR, u'tagType': AtomicTag, u'engHigh': 1.5, u'name': u'Out', u'opcServer': {bindType=parameter, binding={OPC Server}}, u'valueSource': u'opc', u'historyMaxAge': 3}]

# Remove readOnly override with 'pop' function

# Try write config back to original tag
print system.tag.configure(basePath=tagPath, tags=tagConfig[0], collisionPolicy="m")

This results in everything listed in the output of the tagConfig being overriden.

EDIT: managed to remove all overrides by pretty much deleting all config except name:

tagConfig[0] = {'name':'Out'}
print system.tag.configure(basePath=tagPath, tags=tagConfig[0], collisionPolicy="o")

So i suppose the glaring question is why does the config return all these things when they aren’t actually overridden to begin with?

The properties are overridden because the getConfiguration function seemingly returns all non-default values from the tags, and then writing that back to the config then writes those values into the configuration of the UDT instance itself, when really some of this config is part of the UDT definition config.

I think it’s more a mis-understanding of what the getConfiguration function returns and how property overrides are applied, however I do think an option to only return the configuration as it’s seen, for example by copying a tag’s JSON in the tag browser, would be a good addition to the getConfiguration function for instances like this. It is a bit confusing why this function returns differently to the JSON copied from the tag browser, but I think both returned JSON versions are useful for different purposes.

If you really wanted to do it properly now, you would need to get the config of the UDT definition tags and remove the props that those contain from the UDT instances

1 Like

Interesting, i never bothered to Copy JSON from the tag browser, but i see that correctly reports what is overridden as you suggest. I think that would be a great change to the getConfiguration function, which would solve a WHOLE lot of complexity.
And by change, perhaps an optional toggle so that we can have it both ways.

For instance the copy JSON returns this:

{"readOnly":true, "tagGroup": "Direct_Slow", "name": "Out", "tagType":"AtomicTag"}

By Non-Default, do you mean the “Default” properties would be what you see when you click a new standard tag such as an OPC tag?
I can see for instance that by default no tag history is enabled, which would explain why my output of the tag config above has a lot of history stuff there.

But yes, it is very confusing that this “appears” default, as that is what the Parent UDT has been configured as.

@richardNZ15 I think this is the post you were referring to, System.tag.configure incorrectly overriding multiple UDT tag properties

1 Like

Yes i think this is what someone else demonstrated in another thread. Damn…

The other option is to just use the Copy JSON function and apply your logic to that from the clipboard instead of applying it to the results of the getConfiguration function.
I have a collection of python functions that manipulate the contents of the clipboard for things like creating tags from excel and back again. You can then just copy the manipulated JSON back into the tag browser

1 Like

I’ve created an idea for this:

1 Like

So this has been driving me nuts this week whilst trying to work out how best to solve this for a tag comparison tool I am building (to compare tag configurations between different remote gateways). Fortunately I found something that seems like it may be a winner. Specifically system.tag.exportTags was changed in v8.1.8 to return a JSON string if you omit the filePath parameter

This appears to return the same results as the "Copy JSON" option in designer as a large string :slight_smile:


That's awesome to know, cheers!