I get the following error 6 to 10 times when I open a window the first time after launching the Vision project:
Traceback (most recent call last):
File “event:propertyChange”, line 5, in
java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: Dataset can not be null
Ignition v8.0.5 (b2019101516)
Java: Azul Systems, Inc. 11.0.4
If I move to another window in the project and then come back, the error does not happen. Also, it won’t happen when I run the script in designer. Also it seems to function perfectly except for the errors.
The script is short:
1 event.source.parent.getComponent(‘MES Analysis Controller’).refresh()
2 # Get the dataset from the MES Controller and make a dataset called “data”
3 data = event.source.parent.getComponent(“MES Analysis Controller”).data
4
5 formattedData = system.dataset.formatDates(data, “H:m”)
6 table = event.source.parent.getComponent(‘table’)
7 table.data = formattedData
I’ve run this in designer by triggering with pushbuttons and printing the datasets to the console, but it’s never null when I do that.
I feel like I’m missing something really obvious here. Does anyone see anything obviously wrong?
First of all, using this in a property change event, you need to filter out the property change you want to act on. Since you are getting the error 6 to 10 times, that is the number of properties that are changing, therefore your script is running once for each property. Narrow it down to the exact case you want then see if your error returns,
I have no idea about the MES controller or how it works, but I would check permissions on the project. It may have to do with the Legacy Database Access permissions or something related to that. The permissions are under project properties->Client->Permissions
It sounds like your script is running before MES Analysis Controller.data is populated. You could add if data != None on line 4 and indent lines 5-7 under that so they only run if data is not None.
Perhaps there’s a better way. The MES Analysis Controller has an afterUpdate extension function that fires once the data has been refreshed. Running a script from that function would seem to be more logical and will more reliably give you non-null data.