# Extract cell value from table NullPointerException

**URL:** <https://forum.inductiveautomation.com/t/extract-cell-value-from-table-nullpointerexception/20050>\
**Category:** Ignition\
**Created:** [October 9, 2018, 8:04pm UTC](https://forum.inductiveautomation.com/t/extract-cell-value-from-table-nullpointerexception/20050 "2018-10-09T20:04:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dion.botha](https://avatars.discourse-cdn.com/v4/letter/d/46a35a/32.png) [@dion.botha](https://forum.inductiveautomation.com/u/dion.botha)\
**Post date:** [October 9, 2018, 8:04pm UTC](https://forum.inductiveautomation.com/t/extract-cell-value-from-table-nullpointerexception/20050/1 "2018-10-09T20:04:30Z")

</div>

Hi Guys,

I am trying to transfer a particular cell value of a table to a text field using this code on propertyChange of the table.

> event.source.parent.getComponent('Text Field').text = event.source.data.getValueAt(1,4)

This works but it also throws out this error:

> Traceback (most recent call last):  
> File "event:propertyChange", line 1, in   
> java.lang.NullPointerException

> java.lang.NullPointerException: java.lang.NullPointerException

> at org.python.core.Py.JavaError(Py.java:495)  
> at org.python.core.Py.JavaError(Py.java:488)  
> at org.python.core.PyReflectedFunction. **call** (PyReflectedFunction.java:188)  
> at org.python.core.PyReflectedFunction. **call** (PyReflectedFunction.java:204)  
> at org.python.core.PyObject. **call** (PyObject.java:422)  
> at org.python.core.PyObject. **call** (PyObject.java:426)  
> at org.python.core.PyMethod. **call** (PyMethod.java:139)  
> at org.python.pycode.\_pyx170.f$0(event:propertyChange:1)  
> at org.python.pycode.\_pyx170.call\_function(event:propertyChange)  
> 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:636)  
> at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.runActions(ActionAdapter.java:180)  
> at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.access$000(ActionAdapter.java:40)  
> at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter$ActionRunner.run(ActionAdapter.java:286)  
> at java.awt.event.InvocationEvent.dispatch(Unknown Source)  
> at java.awt.EventQueue.dispatchEventImpl(Unknown Source)  
> at java.awt.EventQueue.access$500(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.ProtectionDomain$JavaSecurityAccessImpl.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)  
> Caused by: java.lang.NullPointerException

> Ignition v7.9.9 (b2018081621)  
> Java: Oracle Corporation 1.8.0\_171

---

<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:** [October 9, 2018, 8:10pm UTC](https://forum.inductiveautomation.com/t/extract-cell-value-from-table-nullpointerexception/20050/2 "2018-10-09T20:10:28Z")

</div>

That suggests that your error is from the text field, not the table.

---

<div class="post-metadata">

**Author:** ![dion.botha](https://avatars.discourse-cdn.com/v4/letter/d/46a35a/32.png) [@dion.botha](https://forum.inductiveautomation.com/u/dion.botha)\
**Post date:** [October 9, 2018, 8:28pm UTC](https://forum.inductiveautomation.com/t/extract-cell-value-from-table-nullpointerexception/20050/3 "2018-10-09T20:28:33Z")

</div>

Its just a dumb text field, I don’t know what could be wrong with it…

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [October 9, 2018, 8:36pm UTC](https://forum.inductiveautomation.com/t/extract-cell-value-from-table-nullpointerexception/20050/5 "2018-10-09T20:36:22Z")

</div>

> [@dion.botha](#):
>
> event.source.data.getValueAt(1,4)

The data property is probably null at some point when the window loads (wild guess - it's bound to something, like maybe a tag?)

---

<div class="post-metadata">

**Author:** ![dion.botha](https://avatars.discourse-cdn.com/v4/letter/d/46a35a/32.png) [@dion.botha](https://forum.inductiveautomation.com/u/dion.botha)\
**Post date:** [October 9, 2018, 8:43pm UTC](https://forum.inductiveautomation.com/t/extract-cell-value-from-table-nullpointerexception/20050/6 "2018-10-09T20:43:35Z")

</div>

The table’s data is coming from an SQL query.

The error happens every time the query is polled.

So maybe the script is firing before the SQL query has been polled?

Not sure how to solve this…

---

<div class="post-metadata">

**Author:** ![dion.botha](https://avatars.discourse-cdn.com/v4/letter/d/46a35a/32.png) [@dion.botha](https://forum.inductiveautomation.com/u/dion.botha)\
**Post date:** [October 9, 2018, 8:45pm UTC](https://forum.inductiveautomation.com/t/extract-cell-value-from-table-nullpointerexception/20050/7 "2018-10-09T20:45:08Z")

</div>

Ahhh, just changed the script to be fired on click rather than property change!
