Perspective 8.1.xx Dropdown list - Use VALUE returned

I have a perspective dropdown box being populated (options parameter) by a nx1 dataset returned from a named query. The list looks fine and the selected “value” displays correctly. However when I try to use the “value” property and assign it or use it in a named query call I get an error of
“…Cannot coerce value ‘set([value])’ into type:…”

below is the code line from the Change Script for the VALUE property that’s trying to use the selected value

dbdata = system.db.runNamedQuery(“Get_Stations_ID_Name”,{currentValue.value})

where the namedQuery paremeter shoud be an INT4

dataset used to populate dropdown list:
image

FULL ERROR message:

15:30:39.170 [AWT-EventQueue-0] ERROR com.inductiveautomation.ignition.client.util.gui.ErrorUtil - Error running property change script on Dropdown.props.value: Traceback (most recent call last):
File “function:valueChanged”, line 6, in valueChanged
at com.inductiveautomation.ignition.common.TypeUtilities.coerce(TypeUtilities.java:1422)
at com.inductiveautomation.ignition.common.script.builtin.PyArgumentMap.coerce(PyArgumentMap.java:130)
at com.inductiveautomation.ignition.common.script.builtin.PyArgumentMap.interpretPyArgs(PyArgumentMap.java:82)
at com.inductiveautomation.ignition.common.script.builtin.PyArgumentMap.interpretPyArgs(PyArgumentMap.java:40)
at com.inductiveautomation.ignition.gateway.script.GatewayDBUtilities.interpretWithOptionalProject(GatewayDBUtilities.java:466)
at com.inductiveautomation.ignition.gateway.script.GatewayDBUtilities.runNamedQuery(GatewayDBUtilities.java:375)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
java.lang.ClassCastException: java.lang.ClassCastException: Cannot coerce value ‘set([3L])’ into type: interface java.util.Map

com.inductiveautomation.ignition.common.GenericTransferrableException: Traceback (most recent call last):
File “function:valueChanged”, line 6, in valueChanged
at com.inductiveautomation.ignition.common.TypeUtilities.coerce(TypeUtilities.java:1422)
at com.inductiveautomation.ignition.common.script.builtin.PyArgumentMap.coerce(PyArgumentMap.java:130)
at com.inductiveautomation.ignition.common.script.builtin.PyArgumentMap.interpretPyArgs(PyArgumentMap.java:82)
at com.inductiveautomation.ignition.common.script.builtin.PyArgumentMap.interpretPyArgs(PyArgumentMap.java:40)
at com.inductiveautomation.ignition.gateway.script.GatewayDBUtilities.interpretWithOptionalProject(GatewayDBUtilities.java:466)
at com.inductiveautomation.ignition.gateway.script.GatewayDBUtilities.runNamedQuery(GatewayDBUtilities.java:375)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
java.lang.ClassCastException: java.lang.ClassCastException: Cannot coerce value ‘set([3L])’ into type: interface java.util.Map

at org.python.core.Py.JavaError(Py.java:552)
at org.python.core.Py.JavaError(Py.java:543)
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:190)
at com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction.__call__(ScriptManager.java:523)
at org.python.core.PyObject.__call__(PyObject.java:497)
at org.python.core.PyObject.__call__(PyObject.java:501)
at org.python.pycode._pyx25.valueChanged$1(<function:valueChanged>:11)
at org.python.pycode._pyx25.call_function(<function:valueChanged>)
at org.python.core.PyTableCode.call(PyTableCode.java:171)
at org.python.core.PyBaseCode.call(PyBaseCode.java:308)
at org.python.core.PyFunction.function___call__(PyFunction.java:471)
at org.python.core.PyFunction.__call__(PyFunction.java:466)
at org.python.core.PyFunction.__call__(PyFunction.java:461)
at com.inductiveautomation.ignition.common.script.ScriptManager.runFunction(ScriptManager.java:821)
at com.inductiveautomation.ignition.common.script.ScriptManager.runFunction(ScriptManager.java:805)
at com.inductiveautomation.ignition.gateway.project.ProjectScriptLifecycle$TrackingProjectScriptManager.runFunction(ProjectScriptLifecycle.java:687)
at com.inductiveautomation.ignition.common.script.ScriptManager$ScriptFunctionImpl.invoke(ScriptManager.java:964)
at com.inductiveautomation.ignition.gateway.project.ProjectScriptLifecycle$AutoRecompilingScriptFunction.invoke(ProjectScriptLifecycle.java:752)
at com.inductiveautomation.perspective.gateway.script.ScriptFunctionHelper.invoke(ScriptFunctionHelper.java:106)
at com.inductiveautomation.perspective.gateway.model.PropertyChangeScript.onValueChanged(PropertyChangeScript.java:123)
at com.inductiveautomation.perspective.gateway.property.PropertyTree$Notifier.run(PropertyTree.java:183)
at com.inductiveautomation.ignition.common.util.ExecutionQueue$PollAndExecute.run(ExecutionQueue.java:210)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)

Caused by: com.inductiveautomation.ignition.common.GenericTransferrableException: Traceback (most recent call last):
File “function:valueChanged”, line 6, in valueChanged
at com.inductiveautomation.ignition.common.TypeUtilities.coerce(TypeUtilities.java:1422)
at com.inductiveautomation.ignition.common.script.builtin.PyArgumentMap.coerce(PyArgumentMap.java:130)
at com.inductiveautomation.ignition.common.script.builtin.PyArgumentMap.interpretPyArgs(PyArgumentMap.java:82)
at com.inductiveautomation.ignition.common.script.builtin.PyArgumentMap.interpretPyArgs(PyArgumentMap.java:40)
at com.inductiveautomation.ignition.gateway.script.GatewayDBUtilities.interpretWithOptionalProject(GatewayDBUtilities.java:466)
at com.inductiveautomation.ignition.gateway.script.GatewayDBUtilities.runNamedQuery(GatewayDBUtilities.java:375)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
java.lang.ClassCastException: java.lang.ClassCastException: Cannot coerce value ‘set([3L])’ into type: interface java.util.Map

... 25 common frames omitted

Caused by: com.inductiveautomation.ignition.common.GenericTransferrableException: Cannot coerce value ‘set([3L])’ into type: interface java.util.Map
at com.inductiveautomation.ignition.common.TypeUtilities.coerce(TypeUtilities.java:1422)
at com.inductiveautomation.ignition.common.script.builtin.PyArgumentMap.coerce(PyArgumentMap.java:130)
at com.inductiveautomation.ignition.common.script.builtin.PyArgumentMap.interpretPyArgs(PyArgumentMap.java:82)
at com.inductiveautomation.ignition.common.script.builtin.PyArgumentMap.interpretPyArgs(PyArgumentMap.java:40)
at com.inductiveautomation.ignition.gateway.script.GatewayDBUtilities.interpretWithOptionalProject(GatewayDBUtilities.java:466)
at com.inductiveautomation.ignition.gateway.script.GatewayDBUtilities.runNamedQuery(GatewayDBUtilities.java:375)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at org.python.core.PyReflectedFunction.call(PyReflectedFunction.java:188)
… 22 common frames omitted

In Python, {} around a comma-separated sequence of literals creates a set. system.db.runNamedQuery requires you to pass a dictionary of key: value pairs; e.g.:
dbdata = system.db.runNamedQuery(“Get_Stations_ID_Name”,{"paramName": currentValue.value})
You’ll need to use the appropriate parameter name(s) for your named query.

Thanks that was it…semi-newbie to python… :sweat_smile:

1 Like