# Copy a row from a table to a dataset

**URL:** <https://forum.inductiveautomation.com/t/copy-a-row-from-a-table-to-a-dataset/47328>\
**Category:** Ignition\
**Created:** [June 1, 2021, 9:47pm UTC](https://forum.inductiveautomation.com/t/copy-a-row-from-a-table-to-a-dataset/47328 "2021-06-01T21:47:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![EduardoChega](https://avatars.discourse-cdn.com/v4/letter/e/c5a1d2/32.png) [@EduardoChega](https://forum.inductiveautomation.com/u/EduardoChega)\
**Post date:** [June 1, 2021, 9:47pm UTC](https://forum.inductiveautomation.com/t/copy-a-row-from-a-table-to-a-dataset/47328/1 "2021-06-01T21:47:00Z")

</div>

I have a dataset in a memory tag that is bound to a table on Perspective, I have a button that if I click it adds a row to my dataset which reflects on my table, is there a way to edit the table itself and reflect it to my dataset?

---

<div class="post-metadata">

**Author:** ![EduardoChega](https://avatars.discourse-cdn.com/v4/letter/e/c5a1d2/32.png) [@EduardoChega](https://forum.inductiveautomation.com/u/EduardoChega)\
**Post date:** [June 1, 2021, 9:56pm UTC](https://forum.inductiveautomation.com/t/copy-a-row-from-a-table-to-a-dataset/47328/2 "2021-06-01T21:56:57Z")

</div>

or to copy a row in a table into a dataset in a memory tag?

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [June 1, 2021, 10:24pm UTC](https://forum.inductiveautomation.com/t/copy-a-row-from-a-table-to-a-dataset/47328/3 "2021-06-01T22:24:53Z")

</div>

I’m pretty sure that you will need to write the changes to the table data back to the tag manually, either within the same on edit script you’re using to add the row(s), or via one of the table event handlers such as onEditCellCommit

---

<div class="post-metadata">

**Author:** ![EduardoChega](https://avatars.discourse-cdn.com/v4/letter/e/c5a1d2/32.png) [@EduardoChega](https://forum.inductiveautomation.com/u/EduardoChega)\
**Post date:** [June 1, 2021, 10:30pm UTC](https://forum.inductiveautomation.com/t/copy-a-row-from-a-table-to-a-dataset/47328/4 "2021-06-01T22:30:29Z")

</div>

Thanks for the response, actually I found out how to do it. I went to the event handler “onEditCellCommit” and wrote the following script:

valueToSet = event.value  
#OP011 is the name of my memory tag with the dataset  
#created custom properties for the table to bind tags, data, etc.  
OP011 = self.custom.OP011  
path = self.custom.OP011\_path  
self.props.data = system.dataset.setValue(self.props.data,event[‘row’],event[‘column’], valueToSet)  
system.tag.write(path,system.dataset.setValue(self.custom.OP011,event[‘row’],event[‘column’],valueToSet))

I hope this helps for future references.

---

<div class="post-metadata">

**Author:** ![Cameronin](https://avatars.discourse-cdn.com/v4/letter/c/9fc29f/32.png) [@Cameronin](https://forum.inductiveautomation.com/u/Cameronin)\
**Post date:** [May 25, 2022, 4:35pm UTC](https://forum.inductiveautomation.com/t/copy-a-row-from-a-table-to-a-dataset/47328/5 "2022-05-25T16:35:25Z")

</div>

Hi @EduardoChega  
This is exactly what I’m trying to do. I’m getting there, but there’s a lot of trial and error.  
Would you mind sharing how you scripted the button to add the row to the dataset?  
Thanks!

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [May 25, 2022, 5:15pm UTC](https://forum.inductiveautomation.com/t/copy-a-row-from-a-table-to-a-dataset/47328/6 "2022-05-25T17:15:04Z")

</div>

Eduardo, use the `</>` code formatting button when pasting code. It preserves indentation and applies syntax highlighting.
