Issue with system.tag.writeBlocking

Hello,

I am trying to use a button to write two tags so I followed the example from the documentation where you create a list of tag paths and a list of values to write but when I pass the path list and value list into the writeBlocking function only the last tag is written.
I’ve tried swapping places of the paths and values to see if I had done an error in writing either the path of value but it seems like it is able to write to both tags depending on which one is last in the function.

When I try printing the return from the function I always get a “good” quality from them both, but only the last one is written. Here is my code:

def runAction(self, event):
	"""
	This event is fired when the 'action' of the component occurs.

	Arguments:
		self: A reference to the component that is invoking this function.
		event: An empty event object.
	"""
	
	autoTagpath = self.view.params.DevicePath + "/KommandoReg/Auto"
	manTagPath = self.view.params.DevicePath + "/KommandoReg/Man"
	
	tagList = [autoTagpath,manTagPath]
	valuelist = ["true","false"]
	
	test = system.tag.writeBlocking(tagList,valuelist)
	
	system.perspective.print(message=test

The code i on an “onActionPerformed” event inside of an UDT where a view param for the device UDT is passed. again, I know the path calculation works because ive managed to write to both tags individually via the script by changing positions of the values and paths.

I also tried writing to the individually by using two writeBlocking functions and just passing the raw path and value but I had the same issue

What do you mean ? UDTs don’t have events as far as I’m aware, they’re just a type definition (User Defined Type). The onActionEvent is on the button.

Now, about the issue… That’s a weird one.
Can you try with new tags and absolute paths ?
Like, create 2 memory tags and try writing to those.

side note: Why are you using strings if your tags are booleans ?

You are passing strings in the valuelist. If they’re booleans shouldn’t you be using,

    valuelist = [True, False]
2 Likes

I formulated my post wrong, I meant to say that the “onActionPerformed” is inside of a “popup view” where I am using a view param for the popup view which is the tag path to the UDT instance.

I got an error when trying to use booleans but I was unaware that they were Case Sensitive. I have changed over from strings now even though they evaluate to the same result in Ignition.

I tried using Absolute paths instead but I had the same issue, however when I created 2 memory tags and tried writing to those it worked without any issue. The tags I was originally trying to write to are OPC tags.

It seems like the writeBlocking function works as intended but I don’t know why I am not able to write to both OPC tags when I’m able to write to the memory tags without any issue. I have nothing on the PLC side overwriting any of the tags and I’m able to write to both tags individually.

Hello again

After some testing I have figured out what might be the cause of the issue but I do not know why or how this happens.
It looks like I am able to write to OPC tags as long as they are not part of my UDT structures from the PLC.
The way the UDTs are programmed in Ignition to work well with the Siemens dataset is that there is a “main tag” which takes the entire datatype from the PLC and multiple derived tags that set and get the values from the main tag with the “JsonSet” and “JsonGet” methods.

It seems like writing to the Derived tag with the Tag Path might be the cause for this issue, but I still find it weird that the last tag in the list always works while the ones before it do not get written.
I thought about writing directly to the UDT tag instead, but I was unable to access specific variables in the data structure from the PLC as I do not know the correct path naming convention and was unable to find anything online regarding the naming convention.

Does anyone know how I can read and write data directly to a “Document” datatype tag?

Sounds like the Tag Group these tags belong to doesn’t have the Optimistic Writes setting enabled, which is necessary when doing the derived tag / Document tag setup.

1 Like

This was the issue!

Thanks a lot for the help, now it works!