My name is Felipe. I have spent time finding a solution for an application, but without success. The idea is that every time the dataset has the word “Label Exchance” or even the code “500”, the system returns the row and column they are in, it can be a label, for example. See attached image
Hi @JordanCClark I tested your generic system on a table component, to later use it in my application. but I think I did something wrong. I put the script in propertyChange of a table component. In the end I added the table’s data property to the findData variable and some errors appeared. I will attach them.
`Caused by: java.lang.ClassCastException: org.python.core.PyObjectDerived cannot be cast to org.python.core.PySequence
at com.inductiveautomation.ignition.common.script.builtin.DatasetUtilities.toDataSet(DatasetUtilities.java:487)
at sun.reflect.GeneratedMethodAccessor364.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)
... 25 more
Traceback (most recent call last):
File “”, line 30, in
File “”, line 28, in findEquals
at com.inductiveautomation.ignition.common.script.builtin.DatasetUtilities.toDataSet(DatasetUtilities.java:487)
at sun.reflect.GeneratedMethodAccessor364.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
java.lang.ClassCastException: java.lang.ClassCastException: org.python.core.PyObjectDerived cannot be cast to org.python.core.PySequence
`
I tried your script and it worked flawlessly in the script console. When I move it to a gateway script, it doesn't run. Any idea what could be the issue? TIA.
I am trying to use it in a timer gateway script to look at different clients and count how many times a user is logged in at on a specific PC. It is a timer script.
From Error Log:
com.inductiveautomation.ignition.common.script.JythonExecException: Traceback (most recent call last): File "", line 31, in File "", line 24, in findEquals NameError: global name 'system' is not defined
Caused by: org.python.core.PyException: NameError: global name 'system' is not defined
Example code:
import system
from java.lang import System
sessions = system.util.getSessionInfo()
def findEquals(datasetIn, colName,value,colName2,value2):
# Convert to PyDataSet
dataIn = system.dataset.toPyDataSet(sessions)
import system
headers = list(dataIn.getColumnNames())
dataOut = [row for row in dataIn if (row[colName] == value and row[colName2] == value2)]
return system.dataset.toDataSet(headers, dataOut)
findData = findEquals(sessions, 'username', 'Lockout','address', 'DESKTOP-XXXXXX')
rowCount = findData.getRowCount()
if(rowCount > 0):
system.tag.writeBlocking(['[default]LockoutUserRole'], True)
Gateway event scope bamboozlery.
Don't write scripts in the gateway event, put them in the script library and call them from the event.
Don't import system.
Thanks for your reply. I had the import outside the definition at first, without it inside the definition. Scrambling to try and make it work I thought to actually add it to the definition, as well as "sessions" but copied it to the wrong spot. Stupid error on my part .. its working now. Thank you.