[IGN-3862] system.tag.configure ignores DateTime overrides

Hi,

I have a script to rename a UDT instance and it seems like a datetime member loses its override on system.tag.configure

To reproduce:

Create an instance of a UDT, containing some memory tag members. This is an example UDT definition.

{
  "name": "TestRename",
  "typeId": "",
  "tagType": "UdtType",
  "tags": [
    {
      "valueSource": "memory",
      "dataType": "DateTime",
      "name": "DateTime",
      "formatString": "yyyy-MM-dd h:mm:ss aa",
      "tagType": "AtomicTag"
    },
    {
      "valueSource": "memory",
      "dataType": "Document",
      "name": "Document",
      "tagType": "AtomicTag"
    },
    {
      "valueSource": "memory",
      "dataType": "Boolean",
      "name": "Boolean",
      "tagType": "AtomicTag"
    },
    {
      "valueSource": "memory",
      "name": "Integer",
      "tagType": "AtomicTag"
    },
    {
      "valueSource": "memory",
      "dataType": "String",
      "name": "String",
      "tagType": "AtomicTag"
    },
    {
      "valueSource": "memory",
      "dataType": "Float4",
      "name": "Float",
      "tagType": "AtomicTag"
    }
  ]
}

I use the following script to rename the instance:

def rename(tagPath, newName):
	#Get the current tag config
	try:
		configs = system.tag.getConfiguration(tagPath, True) #Must be recursive to get child config
		name = configs[0]['name']
		baseTagPath = tagPath.replace('/'+name, '')
		configs[0]['name'] = newName
		
		#Check if the destination does not already exist to avoid wiping another tag
		if not system.tag.exists(baseTagPath + '/' + newName):	
			#create the new tag
			system.tag.configure(baseTagPath, configs, "o")
			#Check if create was successful and delete original tag
			if system.tag.exists(baseTagPath + '/' + newName):
				delete(tagPath)

	except Exception as e:
		pass
		
		
def delete(tagPath):
	#Delete, do not care about success
	system.tag.deleteTags([tagPath])
	
		
rename ('[default]Test/name2', 'name1')

Any value that was set in the datetime member is lost. The others preserve their values.

If you print the value of the config, the value is there.

This behaviour is not present when renaming a tag through the tag browser.

I see there used to be a system.tag.rename function, but it appears deprecated. If there is a better way to programmatically rename a tag, please do let me know.

Regards,
Deon

(Using 8.1.7)

Is this a bug or is there a better way of renaming a tag preserving the DateTime overrides?

This does look like a bug. I’ll log a ticket so that we can look into it further.

system.tag.rename() was added in 8.0.2 when functionality was split out from system.tag.move(). As far as I know, it’s not deprecated, but it might be missing some documentation in the manual (I’m looking in to this also). You should still see it in the designer UI:

It looks like a better solution in this scenario.

It looks like the original issue was that system.tag.getConfiguration is outputting the dateTime value in a format that system.tag.Configure doesn’t accept. If it’s converted back to milliseconds before writing it back in, the issue no longer occurs. I’ve updated the post title with the ticket number created for this issue.

1 Like

Thanks for the confirmation.

I’ll give rename a shot. The absence from the documentation put me off using it

Understood, this has been corrected. Thank you for bringing it to our attention.

3 Likes