# Adding row to dataset error

**URL:** <https://forum.inductiveautomation.com/t/adding-row-to-dataset-error/6884>\
**Category:** Ignition\
**Created:** [July 18, 2013, 1:39pm UTC](https://forum.inductiveautomation.com/t/adding-row-to-dataset-error/6884 "2013-07-18T13:39:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![diat150](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@diat150](https://forum.inductiveautomation.com/u/diat150)\
**Post date:** [July 18, 2013, 1:39pm UTC](https://forum.inductiveautomation.com/t/adding-row-to-dataset-error/6884/1 "2013-07-18T13:39:39Z")

</div>

I have a Dataset type custom property on my root container. I would like to add a row to that dataset using the following code:

> [@](#):
>
> dropdown = event.source.parent.test  
> newRow = [5, "New Option"]  
> dropdown.data = system.dataset.addRow(dropdown.data, newRow)

I get this error:

Traceback (most recent call last):  
File "event:actionPerformed", line 3, in   
TypeError: addRow(): 1st arg can't be coerced to com.inductiveautomation.ignition.common.Dataset

```
at org.python.core.PyException.fillInStackTrace(PyException.java:70)
at java.lang.Throwable.<init>(Throwable.java:181)
at java.lang.Exception.<init>(Unknown Source)
at java.lang.RuntimeException.<init>(Unknown Source)
at org.python.core.PyException.<init>(PyException.java:46)
at org.python.core.PyException.<init>(PyException.java:43)
at org.python.core.PyException.<init>(PyException.java:61)
at org.python.core.Py.TypeError(Py.java:235)
at org.python.core.PyReflectedFunction.throwError(PyReflectedFunction.java:209)
at org.python.core.PyReflectedFunction.throwBadArgError(PyReflectedFunction.java:312)
at org.python.core.PyReflectedFunction.throwError(PyReflectedFunction.java:321)
at org.python.core.PyReflectedFunction. __call__ (PyReflectedFunction.java:167)
at org.python.core.PyReflectedFunction. __call__ (PyReflectedFunction.java:204)
at org.python.core.PyObject. __call__ (PyObject.java:404)
at org.python.core.PyObject. __call__ (PyObject.java:408)
at org.python.pycode._pyx39.f$0(<event:actionPerformed>:3)
at org.python.pycode._pyx39.call_function(<event:actionPerformed>)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1275)
at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:548)
at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.runActions(ActionAdapter.java:155)
at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.invoke(ActionAdapter.java:266)
at com.inductiveautomation.factorypmi.application.binding.action.RelayInvocationHandler.invoke(RelayInvocationHandler.java:55)
at $Proxy17.actionPerformed(Unknown Source)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$400(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

```

Ignition v7.5.10-rc1 (b1455)  
Java: Sun Microsystems Inc. 1.6.0\_38

If I tell the script to write to a dataset of a dropdown components dataset like the example in the manual shows, it works correctly. I guess I need to know what the difference is between the custom property dataset and the dropdowns dataset.

---

<div class="post-metadata">

**Author:** ![Step7](https://avatars.discourse-cdn.com/v4/letter/s/45deac/32.png) [@Step7](https://forum.inductiveautomation.com/u/Step7)\
**Post date:** [July 18, 2013, 1:59pm UTC](https://forum.inductiveautomation.com/t/adding-row-to-dataset-error/6884/2 "2013-07-18T13:59:36Z")

</div>

Hard to tell from here, but is ‘test’ a dataset in the root container? If so, you could try this:

```auto
dropdown = event.source.parent
newRow = [5, "New Option"]
dropdown.test = system.dataset.addRow(dropdown.test, newRow)
```

Just a thought.

---

<div class="post-metadata">

**Author:** ![diat150](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@diat150](https://forum.inductiveautomation.com/u/diat150)\
**Post date:** [July 18, 2013, 2:02pm UTC](https://forum.inductiveautomation.com/t/adding-row-to-dataset-error/6884/3 "2013-07-18T14:02:36Z")

</div>

yes test is the custom property on the root container. What you proposed threw a no attribute data error.

weird thing is that I can bind the custom property dataset to the dropdown dataset or to a table dataset and add the new row to the table or dropdowns dataset and it carries over to the custom property dataset with no issue.

---

<div class="post-metadata">

**Author:** ![diat150](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@diat150](https://forum.inductiveautomation.com/u/diat150)\
**Post date:** [July 18, 2013, 3:16pm UTC](https://forum.inductiveautomation.com/t/adding-row-to-dataset-error/6884/4 "2013-07-18T15:16:48Z")

</div>

One of my coworkers figured it out

> [@](#):
>
> dropdown = event.source.test  
> newRow = [5, "New Option"]  
> event.source.test = system.dataset.addRow(dropdown, newRow)

---

<div class="post-metadata">

**Author:** ![uTewell](https://avatars.discourse-cdn.com/v4/letter/u/e274bd/32.png) [@uTewell](https://forum.inductiveautomation.com/u/uTewell)\
**Post date:** [August 9, 2019, 6:54pm UTC](https://forum.inductiveautomation.com/t/adding-row-to-dataset-error/6884/5 "2019-08-09T18:54:20Z")

</div>

Thank you so much for posting this. The example in the manual is wrong or worded incorrectly as I have been copying and pasting it and also could not get it to work.

This example in the manual needs to be fixed.

---

<div class="post-metadata">

**Author:** ![Robert.McKenzie](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/robert.mckenzie/32/4134_2.png) [@Robert.McKenzie](https://forum.inductiveautomation.com/u/Robert.McKenzie)\
**Post date:** [August 9, 2019, 9:07pm UTC](https://forum.inductiveautomation.com/t/adding-row-to-dataset-error/6884/6 "2019-08-09T21:07:38Z")

</div>

Hello,

It’s been a while since this post but I wanted to point out that the example in the user manual has long since been updated.

For anyone coming into this thread with a similar problem, the real issue is likely in the last line. If you did something like:

```auto
component.property = dataset

```

Then everything will work because you are setting the value to a property on a component. If you do something like:

```auto
compDataset = component.property
compDataset = dataset

```

Then this will not work because you are setting one dataset to be equal to another without saving back to the component. The component.property in the last line makes all the difference.
