# Modify element of tag array from table cell

**URL:** <https://forum.inductiveautomation.com/t/modify-element-of-tag-array-from-table-cell/93041>\
**Category:** Ignition\
**Tags:** perspective, scripting\
**Created:** [July 10, 2024, 9:52pm UTC](https://forum.inductiveautomation.com/t/modify-element-of-tag-array-from-table-cell/93041 "2024-07-10T21:52:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![face\_plant](https://avatars.discourse-cdn.com/v4/letter/f/e495f1/32.png) [@face\_plant](https://forum.inductiveautomation.com/u/face_plant)\
**Post date:** [July 10, 2024, 9:52pm UTC](https://forum.inductiveautomation.com/t/modify-element-of-tag-array-from-table-cell/93041/1 "2024-07-10T21:52:44Z")

</div>

Hello! I have a PLC which has a global variable (named `SystemVars`) that is an array of `iSystemVars` structs. I am using Ignition Perspective and want to create a table that displays the structs that makeup `SystemVars`, and have the `value` column be editable in such a way that the modified value is propagated down to the PLC. I am able to edit the table cell, but the modified value does not propagate to the PLC.

```st
TYPE iSystemVar : STRUCT
   name: string;
   value: INT;
END_STRUCT
END_TYPE

```

My PLC broadcasts the `SystemVars` variable on it's OPC UA server which I have created a tag for. So far, I have been able to create a table in Perspective that is able to take the `SystemVars` tag and populate the table.

Since the tag is of type `String`, I have the `data` prop of the table binded to the following script:

```python
def transform(self, value, quality, timestamp):
	import json
	
	# retrieve and format the raw tag data into something sensible
	raw_tag = system.tag.readBlocking("[edge]systemConfig/SystemVars")[0].value
	sys_vars= json.loads(raw_tag) # arr[dict[str, str/float]]
	
	cols = ["Name", "Value"]
	rows = []
	
	for sv in sys_vars:
		if sv["index"] == -1: # empty / placeholder var
			continue
		tmp = []
		tmp.append(sv["name"])
		tmp.append(sv["value"])
		rows.append(tmp)
	
	# return the dataset with the desired cols&rows
	return system.dataset.toDataSet(cols, rows)

```

To edit the table cell, I am using the following script for the `onEditCellCommit` component event.

```python
def runAction(self, event):
       # update the table's data prop to reflect the change
	self.props.data = system.dataset.setValue(
		self.props.data, 
		event.rowIndex, 
		event.column, 
		event.value
	)
    # write the new array to the tag
	system.tag.writeBlocking(["[edge]systemConfig/SystemVars"], [self.props.data])

```

With this script, I am able to edit the cells in the `Value` row, but the modified value does not propagate to the PLC. The `SystemVars` array in the PLC does not change. No errors or anything.

I've made sure that the tag is not read-only, and that I have 2 way communication enabled in Perspective. Any ideas? Please let me know if I need to clarify anything or offer more information. Thank you!!

---

<div class="post-metadata">

**Author:** ![simeonw](https://avatars.discourse-cdn.com/v4/letter/s/4da419/32.png) [@simeonw](https://forum.inductiveautomation.com/u/simeonw)\
**Post date:** [July 11, 2024, 1:47am UTC](https://forum.inductiveautomation.com/t/modify-element-of-tag-array-from-table-cell/93041/2 "2024-07-11T01:47:48Z")

</div>

I see you have defined the tag data type as a STRING. You might be better to read the tag in as a Document (JSON) data type, as that is how Ignition OPC UA reads in and write to structs.

> [@OPC UA struct data type?](https://forum.inductiveautomation.com/t/opc-ua-struct-data-type/26905/2):
>
> You can take advantage of reading whole structs in OPC UA servers as of Ignition 7.9.12 and 8.0.0. When you bring the tag in you’ll notice Ignition presents a JSON value. The strategy here is a little involved but it works. For each of the UDTs you’ll be subscribing to in the PLC you make a corresponding UDT in Ignition. It should have a “Source” OPC tag member that will correspond to the Node with the struct value in the server and as a result have a JSON value in Ignition. Then for each memb…

You are also attempting to write the **data** prop directly to the tag. I imagine this would be a dataset, rather than JSON, based on the function you are using to modify the data in run data.

If you look at the **QualityCode** returned by the **system.tag.writeBlocking** , you will likely see that it has failed to write to the tag. Try converting your table dataset back to JSON and then writing that to the tag.

As a quick check, you could dump the live tag value in the script console, then also dump the updated value that you are writing back and check whether the structures match.
