Scripting error

The following error is occured by the script below it. Any Ideas?
Traceback (innermost last):
File “”, line 28, in ?
TypeError: Unable to convert row 5, column 1 to type class java.lang.String

at org.python.core.Py.TypeError(
at com.inductiveautomation.factorypmi.application.script.builtin.DBUtilities.toDataSet(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.python.core.PyReflectedFunction.__call__(
at org.python.core.PyReflectedFunction.__call__(
at org.python.core.PyObject.__call__(
at org.python.core.PyObject.invoke(
at org.python.pycode._pyx3.f$0(<event>:28)
at org.python.pycode._pyx3.call_function(<event>)
at org.python.core.Py.runCode(
at com.inductiveautomation.factorypmi.application.script.ScriptManager.runCode(
at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.runActions(
at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.invoke(
at com.inductiveautomation.factorypmi.application.binding.action.RelayInvocationHandler.invoke(
at $Proxy1.mouseClicked(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.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at Source)


[code]headers = [“ndx”,“phid”]
data = []

#ds = event.source.parent.SWControlDataSet
#ds[0,0] = fpmi.db.
#ds[1,0] = event.source.parent.DOphid
if ‘FPMIAdministrator’ in

if fpmi.gui.confirm(‘Are you sure you want to send a control to ’ +event.source.parent.SWName +’?’, ‘Confirm’):

	fpmi.gui.openWindow("SwitchControl",{"DataSet":fpmi.db.toDataSet(headers, data),"SwitchName":event.source.parent.SWName})

fpmi.gui.errorBox(‘Insufficient security privileges.’)[/code]

Hi Qurban,

Please let us know that the datatype of
event.source.parent.DIOCFaultDNC (row zero)
event.source.parent.AIPhaseAphid (row five)


event.source.parent.DIOCFaultDNC is a string.
event.source.parent.AIPhaseAphid is an integer.

there’s your problem. A dataset is a table of data. Each column has a name and a datatype. The fpmi.db.toDataSet function uses the first row it sees to determine the datatypes for the columns. So, it is seeing the string on row 0 column 1, and saying “ok, column 1 is a String”.

Then it gets to row 5, and you give it an integer for column 1’s value. It doesn’t like this. You can convert the value to a string manually to make it happy:

Change the line data.append(["AIPhaseA",event.source.parent.AIPhaseAphid]) to data.append(["AIPhaseA",str(event.source.parent.AIPhaseAphid)])

The function shouldn’t be so picky - I’ll make a note of it so that we can make it more lenient in the future.

Hope this helps,

Out of curiosity. What’s that monster script doing?

The script is executed on a ‘mouse click’, which opens another window and the dataset contains the parameters which are passed to the new window. From your(Nathan) comment it seems like this is not the best way to do it. My guess is using the ‘Navigation’ tab under the ‘Action Configuration’ window to pass parameters might be easier. Is that correct?. I inherited the project and am trying to make it work.
From Carls comment it seems like a dataset can contain only one type of variables. Is that Correct?.

Yeah, you can pass variables directly using the a navigation script. Each passed variable corresponds to a dynamic property on the root container of the window you’re openening. From your script, it doesn’t look like it makes much sense to pass these variables in a dataset…

Of course, the other window’s bindings are all going to have to be re-done if you decide to re-do it.

A dataSet can contain any number of types of variables. Normally these types are statically defined. If the source is an SQL database, or how you used a Jython script, the column types were determined automatically.

[quote=“qurban”]From Carls comment it seems like a dataset can contain only one type of variables. Is that Correct?.

For the future, it’s really easy to do as Carl described above. Simple, no scripting necessary!