Extract cell value from table NullPointerException

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

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

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

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

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…

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