I’m attempting to perform navigation during a Barcode Scan Event, where when I scan the barcode the perspective Session Barcode Scanned Event constructs a page
url based off of the text of the barcode. From my logging, the url is being constructed properly, but my Gateway logs are declaring an Illegal Argument Exception:
com.inductiveautomation.perspective.gateway.script.PerspectiveScriptingFunctions.lambda$operateOnPage$18(PerspectiveScriptingFunctions.java:564) at
com.inductiveautomation.perspective.gateway.script.PerspectiveScriptingFunctions.operateOnSession(PerspectiveScriptingFunctions.java:606) at
com.inductiveautomation.perspective.gateway.script.PerspectiveScriptingFunctions.operateOnPage(PerspectiveScriptingFunctions.java:547) at
com.inductiveautomation.perspective.gateway.script.PerspectiveScriptingFunctions.navigate(PerspectiveScriptingFunctions.java:78) at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.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: No perspective page attached to this thread.
The triggering code from the Perspective Session Barcode Scanned Event:
system.perspective.navigate(page=data.text)
I’ve also tried
system.perspective.navigate(page=data.text,sessionId=session.props.id)
but the IAE remained.
Could this stem from the fact that the “camera” screen is displayed while the script is executing?
If I modify the Session Barcode Scanned Event to write to a session prop, and I move the navigation to a component on a page which is bound to the session prop, and perform the navigation as part of an onChange script, the navigation performs as expected.