[SOLVED] What is the syntax for sending a message from a popup in Perspective to refresh a binding on the root of a view?

I have a view called main. I want to refresh a binding on main from a script running in a popup window called my_popup.

The code on a button in my_popup is:

messageType = 'tbl_Refresh_Data'
system.perspective.sendMessage(messageType, scope='page')

Back on my view called main on the root I have a message handler called tbl_Refresh_Data listening in the page scope. The code on the message handler script is:


When I press the button on my_popup I get the gateway error message in the logs:

	Error running listCells/main@C/root.onMessageReceived(self, payload): Traceback (most recent call last): File "<function:onMessageReceived>", line 3, in onMessageReceived at com.inductiveautomation.perspective.common.api.PropertyKey.fromString(PropertyKey.java:48) at com.inductiveautomation.perspective.gateway.script.ComponentModelScriptWrapper$SafetyWrapper.refreshBinding(ComponentModelScriptWrapper.java:93) at jdk.internal.reflect.GeneratedMethodAccessor202.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: Invalid property key - no scope defined: self.custom.cells 

which seems to be telling me that "self.custom.cells" doesn't exist however I picked "self.custom.cells" from the built in binding selector.

Does anyone know what I am doing wrong? I am new to Perspective message handlers so I could be making a mistake somewhere.

The manual shows that the syntax is
system.perspective.sendMessage(messageType, payload, [scope], [sessionId], [pageId])
Note that payload isn't optional so you need to add an empty dictionary, payload = {}. See if

messageType = 'tbl_Refresh_Data'
system.perspective.sendMessage(messageType, payload = {}, scope='page')

does the job.

The error message, Invalid property key - no scope defined: self.custom.cells is a little confusing but I suspect that it has taken your scope parameter as the payload parameter and then found the third parameter was missing.



Try deleting the self before self.custom.cells as you have already defined self before refreshbinding.



I thought so but it appears that payload is also optional.

This was the solution... a very strange issue and annoying.