Getting "object has no attribute" error in Msg Hdlr for custom property on View Root

Hi have a Message Handler on the root of a Perspective view.
In the script I am assigning a varialbe to the value contained in a root.custom.property.
When this script runs I get the following error:

com.inductiveautomation.ignition.common.script.JythonExecException: Traceback (most recent call last): File "", line 11, in onMessageReceived AttributeError: 'com.inductiveautomation.perspective.gateway.script' object has no attribute 'workOrderQuantity'
at org.python.core.Py.AttributeError(Py.java:207)
at org.python.core.PyObject.noAttributeError(PyObject.java:1032)
at org.python.core.PyObject.__getattr__(PyObject.java:1027)
at org.python.pycode._pyx187.onMessageReceived$1(:12)
at org.python.pycode._pyx187.call_function()
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:822)
at com.inductiveautomation.ignition.common.script.ScriptManager.runFunction(ScriptManager.java:806)
at com.inductiveautomation.ignition.gateway.project.ProjectScriptLifecycle$TrackingProjectScriptManager.runFunction(ProjectScriptLifecycle.java:687)
at com.inductiveautomation.ignition.common.script.ScriptManager$ScriptFunctionImpl.invoke(ScriptManager.java:965)
at com.inductiveautomation.ignition.gateway.project.ProjectScriptLifecycle$AutoRecompilingScriptFunction.invoke(ProjectScriptLifecycle.java:752)
at com.inductiveautomation.perspective.gateway.script.ScriptFunctionHelper.invoke(ScriptFunctionHelper.java:101)
at com.inductiveautomation.perspective.gateway.model.MessageHandlerCollection$MessageHandlerImpl$1.lambda$invoke$0(MessageHandlerCollection.java:80)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
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: org.python.core.PyException: Traceback (most recent call last): File "", line 11, in onMessageReceived AttributeError: 'com.inductiveautomation.perspective.gateway.script' object has no attribute 'workOrderQuantity'

The Custom Property is shown in the screen grab below:

The script is as follows:

	self.refreshBinding("custom.dsWOTotals")
	self.refreshBinding("custom.workOrderOpSubmitted")
	self.refreshBinding("custom.qtyCompleted")
	self.refreshBinding("custom.qtyRejected")
	self.refreshBinding("custom.workOrderStatus")
	self.refreshBinding("custom.workOrderQuantity")
	self.refreshBinding("custom.workOrderPartNumber")
	self.refreshBinding("custom.enabelWorkOrderEdit")
	qty = self.custom.workOrderQuantity
	self.view.params.qtyOrdered = qty

Note: I set the qty variable = to the custom property to isolate it from the line setting the view’s parameter.
As I used the Property Browser in the script editor for the message handler, I know the spelling and path to the property are both correct.

Any ideas why I’m getting this error?
The error also generates after I’ve saved the view, closed the project, and re-open the project and view (the message handler is called by an onStartup script in the view to refresh the data bindings in the view).

Thanks.

.refreshBinding() is not synchronous. You’ve told custom.workOrderQuantity to refresh and then you immediately reference its value. Can’t count on that. You’ll need a propertyChange action on the property to know the value is available. Or a binding.

Thanks Phil.
I had not even considered that.
There is so much to know about Ignition and I have very limited free gray matter! :upside_down_face:

Hmm, refreshBinding looks like it’s attempting to be synchronous…

@MikeAllgood, before you attempt to assign, can you try adding:

system.perspective.print(type(self.custom))
system.perspective.print(dir(self.custom))

You are calling these in the root or the component above the root?

The refresh Message Handler script, that this script is in, is on the root of the view. The refreshBinding functions are working properly. It’s the use of self.custom.workOrderQuantity that is throwing the error.

I’m not sure anyone answered the actual question. The bindings are may be out of date as pointed out, but the object should still exist, which is the error.
I was having the same issue and I am not doing any refreshing. Things were working fine in the designer but I was getting an error stating that a custom property did not exist when running a session. When I closed the designer and reopened it, I found I did have the same error.
I found was there were custom properties that were disappearing from the object, but not the one that I was getting the error for. When I added the two missing parameters back, their bindings would also magically reappear. This was repeatable, close the designer, reopen and they are gone. What I found was that I had changed the name of an object that was used in the bindings for those two parameters and not fixed the bindings. Once I fixed that, all was well. I have no idea why it was giving an error for a parameter that was not actually disappearing or why the system would be programmed to make parameters invisible if they had a problem with the binding.