Hi Guys,
I have a dropdown list who's choices comes from the following SQL query:
SELECT OrderNo as [Order #],
Priority
FROM vwLots
WHERE RouteStepName = 'VA'
AND LotID NOT LIKE 'A%'
AND LotID NOT LIKE 'OT%'
ORDER BY Priority ASC, DueDate ASC
Where 'OrderNo' is a string and 'Priority' is an integer.
The 'Table Display Mode' property = 'Table' so the user can see a bunch of other information (with column headings) about what they are selecting.
If I do no further configuration the dropdown list comes through as I expect however when the user makes a selection, the dropdown list displays 'Priority'. I would like 'OrderNo' to be displayed instead.
I can achieve this by making the 'Selected Label' property bound the 'Selected String Value' property (is there a better way to do this?).
The issue I am having is if the user selects the same choice as what was there before, the dropdown list displays 'Priority' again with no error...
Furthermore, once a choice is made, I would like to populate some text fields on the window with 'OrderNo' using the following script on focusLost:
QueryString = ("""
SELECT OrderNo as [Order #],
Priority
FROM vwLots
WHERE RouteStepName = 'VA'
AND LotID NOT LIKE 'A%%'
AND LotID NOT LIKE 'OT%%'
AND OrderNo = '%s'
ORDER BY Priority ASC, DueDate ASC""" % event.source.selectedLabel)
QueryTable = system.db.runQuery(QueryString, "MES")
event.source.parent.getComponent('TP_ON').text = QueryTable[0][0]
This works fine except (again) when the user selects the same option as what was there before- this time I get the following error:
Traceback (most recent call last):
File "event:focusLost", line 13, in
IndexError: Row index 0 out of range.
at org.python.core.Py.IndexError(Py.java:250)
at com.inductiveautomation.ignition.common.script.builtin.DatasetUtilities$PyDataSet.getitem(DatasetUtilities.java:124)
at sun.reflect.GeneratedMethodAccessor152.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.python.core.PyReflectedFunction.call(PyReflectedFunction.java:186)
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.core.PyMethod.call(PyMethod.java:124)
at org.python.core.PyMethod.call(PyMethod.java:115)
at org.python.core.PyObjectDerived.getitem(PyObjectDerived.java:900)
at org.python.pycode._pyx141.f$0(event:focusLost:13)
at org.python.pycode._pyx141.call_function(event:focusLost)
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.invoke(ActionAdapter.java:271)
at com.inductiveautomation.factorypmi.application.binding.action.RelayInvocationHandler.invoke(RelayInvocationHandler.java:57)
at com.sun.proxy.$Proxy21.focusLost(Unknown Source)
at java.awt.AWTEventMulticaster.focusLost(Unknown Source)
at java.awt.Component.processFocusEvent(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.KeyboardFocusManager.redispatchEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(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.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.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.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)
Ignition v7.9.9 (b2018081621)
Java: Oracle Corporation 1.8.0_171