# Updating a Tag's custom DataSet property

**URL:** <https://forum.inductiveautomation.com/t/updating-a-tags-custom-dataset-property/62675>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [August 4, 2022, 2:47pm UTC](https://forum.inductiveautomation.com/t/updating-a-tags-custom-dataset-property/62675 "2022-08-04T14:47:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahersh](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@ahersh](https://forum.inductiveautomation.com/u/ahersh)\
**Post date:** [August 4, 2022, 2:47pm UTC](https://forum.inductiveautomation.com/t/updating-a-tags-custom-dataset-property/62675/1 "2022-08-04T14:47:01Z")

</div>

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:

```auto
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

```

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/c/ec542cf496d6df6d9ebfe8bc02081f551d5e7e40.png)

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?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 4, 2022, 3:26pm UTC](https://forum.inductiveautomation.com/t/updating-a-tags-custom-dataset-property/62675/2 "2022-08-04T15:26:55Z")

</div>

I’m guessing custom properties cannot be datasets. Or need to be written outside of `system.tag.configure`. (That isn’t intended to be heavily used at runtime–use `system.tag.write*`.)

---

<div class="post-metadata">

**Author:** ![ahersh](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@ahersh](https://forum.inductiveautomation.com/u/ahersh)\
**Post date:** [August 4, 2022, 3:32pm UTC](https://forum.inductiveautomation.com/t/updating-a-tags-custom-dataset-property/62675/3 "2022-08-04T15:32:54Z")

</div>

A DataSet is supported:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/3/337c093e7c5663513d2efa66cce9686067f15a71.png)

> That isn’t intended to be heavily used at runtime

That's fair, but this will only be used to store configuration updates made by a user, so once a day maybe? More often than not, it will go unused for weeks/months.

> use `system.tag.write*` .

But I've seen system.tag.write mentioned elsewhere, but doesn't that only apply to the tag's value? I'm trying to add extra configuration information to a tag.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 4, 2022, 3:42pm UTC](https://forum.inductiveautomation.com/t/updating-a-tags-custom-dataset-property/62675/4 "2022-08-04T15:42:30Z")

</div>

> [@ahersh](#):
>
> doesn’t that only apply to the tag’s value?

No, most (all?) properties are readable & writeable using normal methods. The tagpath ends with a dot and the property's proper name.

I wouldn't use spaces in property names.

---

<div class="post-metadata">

**Author:** ![ahersh](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@ahersh](https://forum.inductiveautomation.com/u/ahersh)\
**Post date:** [August 4, 2022, 3:59pm UTC](https://forum.inductiveautomation.com/t/updating-a-tags-custom-dataset-property/62675/5 "2022-08-04T15:59:33Z")

</div>

Ah sweet, didn’t realize a property name could be specified, thanks!

This does the trick:

```auto
# Get the current configuration
ds = system.tag.readBlocking(['[default]Test.sample_table'])[0].value

# Add new value
username = 'adam'
val = 5
ds = system.dataset.addRow(ds, [username, val])
	
# Write the new configuration back
system.tag.writeBlocking('[default]Test.sample_table', ds)

```
