DataSet in Tag Event Script giving me errors

I have been trying to figure this out for a couple hours with no luck. I am attempting to write a ‘Value Change’ ‘Tag Event Script’ to read values from a Data Set. I’m using 8.0.12

A simplified version of my code attempt is below. I can’t read a DataSet from a query tag and write an indexed value to another tag without getting an error. Realistically I’ll need to loop through the dataset to extract some data. But, I’m trying to minimize the code here, I need help getting past the easy stuff. I keep getting errors when trying to access values in the data set.

If I do this, it works fine. The dataset shows up in the newTag and no gateway errors!

rType="[.]../QueryTag").value #read tag
pyrType =system.dataset.toPyDataSet(rType) #make it a pyDataSet
rTypeCount = pyrType.getRowCount() #get number of rows

system.tag.write("[.]newTag",pyrType) #write data set to a newTag


If I do this, it writes the correct value (“1”) to the tag but I still get an error “Row index 0 out of range”


And, if I change the row index, it writes the correct value (“6”) to the tag but I still get an error “Row index 5 out of range”



Even this retrieves the correct value (“Set2”) but I still get an error “Row index 5 out of range”


Also, if I try this, I get an error saying the column ‘IgnitionKeyWord’ Column doesn’t exist. But it DOES return the correct value and write it to the tag.


But if I run this, It return a 1 (as expected) with no errors.


If I try the ‘getValueAt(row,col)’ function I get the same behavior with a slightly different error “ArrayIndexOutOfBoundsException”

I am so confused, I don’t even know what to ask. Why would I be getting gateway errors if it’s retrieving the correct values from the dataset? Am I missing something. I’m planning to loop through the data set and extract values from it so they can be written to other tags. I’ll have a lot of errors in the gateway log if just ignore them.

Try checking for the number of rows to be greater than 0 before processing the dataset.

Since it’s on a query, I suspect the tag is getting cleared before the updated dataset is being written. That means two events for the price of one.

OK…Hear me out…
I think I know what’s causing the errors I’m seeing but I don’t understand why.
As I said, when I was calling the system.tag.write("tag",dataset[][]) function it does write the value to the tag but I get an error in the gateway logs.

Yesterday I was reading the initial dataset tag using a relative tag path"[.]../QueryTag").value

I just tried to read the tag with an absolute path and I get NO errors."[default]QueryTag").value

Why would using the relative vs actual tag path make a difference and cause gateway errors?

I had some time this afternoon to look at this. Honestly, I haven’t been able to replicate the issue using relative paths. :confused:

That’s crazy. I appreciate you spending some time on this. I’ll start a new blank project tonight and try to replicate with some simple tags

I don’t know if I was clear on my tags but the tag event script is from a tag within a UDT and I’m reading a dataset from another UDT instance.

I’ll try to post a copy of my test project here.

1 Like

This has been driving me nuts so I just went ahead and made a new project with a new set of tags to demonstrate. I tried to attach it here. It’s a backup of the project and the tags used. The ‘Value Changed’ ‘tag event script’ is implemented in the BatchNumber tag of the Device UDT

While creating this test project, I have learned that the error is only occurring initially. What I mean is if I open the tag event script editor, make changes, click ‘commit’, and then click apply (in the ‘tag editor’ window) the script automatically fires and I get the errors. This was the problem I have been seeing and it does also occur in this new test project with test tags.

However, the error does not seem to persist. Once the script is in place and it is fired from the tag actually changing the errors do not occur. In the test example, changing the BatchNumber parameter of the ‘Room’ tag (an instance of the UDT Room) causes the ‘Device#’ BatchNumber tags to update.

So… It seems that this is not a major issue after all. I did however spend a lot of time try to avoid having the errors occur.

I’m not sure why the errors occur initially but it did lead me down a deep rabbit hole and it’s a little miss leading. I don’t know if it should be classified as a bug or if there’s a good explanation for the behavior.

Thank you @JordanCClark for taking some time to look at this. Hopefully the attached is enough to put together a test project if someone wants to confirm. (I’ve tested on both 8.0.11 and 8.0.12, which are basically identical)

tags.json (274 Bytes) (2.0 KB)