I am trying to assign a value to a text field based off the results of an expression binding.
On the text field I am using the Binding type “Property” "Expression
Within the expression I have:
runScript("project.Defines.named")
which calls the function
import datetime
window = system.gui.getWindow("Scan Barcode")
snum = window.getRootContainer().getComponent("Text Field 2").text
if snum != "" or snum != 0000000000:
params = {"myValueX":snum}
snum_result = system.db.runNamedQuery("query",params)
return snum_result
else:
snum_result = "Invalid"
return snum_result
when run the Text field displays
Dataset [1R ⅹ 54C]
How do I get a specific value, say row 0 column 36 or [0,36]? I have tried to adjust the expression to pass the row and column I am looking for and receive the error:
[AWT-EventQueue-2] ERROR com.inductiveautomation.factorypmi.designer.property.configurators.ExpressionConfigurator - Type mismatch in operation ‘Dataset Subscript’: expected ‘Dataset’, found ‘Object’
I want the named query to pull all data associated with value in Text Field 2 as that is the index key. Overall the 54 columns in that row will get distributed to different fields.
I can set each field to run a sql query to get the data, but that runs 54 queries for one page.
The end result is I want the user to scan a barcode, the barcode gets parsed to a specific serial number that goes into Text Field 2. Some background magic occurs and the rest of the page is filled out with the data from the database.
Please advise on my mistakes or is there a better way?