I would like to store a custom DataSet property in tags, then manipulate that DataSet’s contents via scripting.
I’m running into serialization/type issues with the property.
To illustrate the problem, the following should create a new tag with a custom DataSet property.
Then the tag is retrieved again, a row added to the existing data set, then written back.
The 2nd step fails as the original DataSet is stored as a “{document}” in the Tag:
basePath = '[default]'
# Create a new tag
tags = [
{
"name": "Test",
"sample table": system.dataset.toDataSet(['name', 'value'], [['adam', 123]])
}
]
system.tag.configure(basePath, tags, "o")
# OUTPUT: [Good]
# Add to the tag's sample table
tags = system.tag.getConfiguration('[default]Test', False)
tags[0]['sample table'] = system.dataset.addRow(tags[0]['sample table'], ["adam", 1])
system.tag.configure(basePath, tags, "o")
# OUTPUT:
# Traceback (most recent call last):
# File "<input>", line 17, in <module>
# TypeError: addRow(): 1st arg can't be coerced to com.inductiveautomation.ignition.common.Dataset
I’ve also tried converting the “system.dataset.toDataSet” result to a PyDataSet, but then it’s stored as an “{Array}” in the Tag.
The same kind of problem occurs if I pre-create the tag and its custom DataSet property.
In that case, when I read the tag, the property type is a proper DataSet that I can add to.
But when I write it back to the tag via configure then it’s converted to a “{document}”, causing subsequent updates to fail.
Thoughts?