I am trying to create a global popup(popup that comes up on any page when called). I have tried several methods but the most affective method i have so far is this. I have created a script on the startup of my home page that get the pageID and sets it to a memory tag. It looks like this:
I then created two custom session variables. One that is bound to the PageLoaded tag and another that is bound to a variable that I can change. On the variable that i can change i created a change script that runs an openPopup and uses the PageLoaded variable to set the pageId of the openPopup. The script looks like this:
The popup comes up and works but I am getting this error in my logger and in my session designer:
Error running property change script on session.custom.OpenPopup: Traceback (most recent call last): File "<function:valueChanged>", line 4, in valueChanged at com.inductiveautomation.perspective.gateway.script.AbstractScriptingFunctions.lambda$operateOnPage$0(AbstractScriptingFunctions.java:57) at com.inductiveautomation.perspective.gateway.script.AbstractScriptingFunctions.operateOnSession(AbstractScriptingFunctions.java:120) at com.inductiveautomation.perspective.gateway.script.AbstractScriptingFunctions.operateOnPage(AbstractScriptingFunctions.java:47) at com.inductiveautomation.perspective.gateway.script.PerspectiveScriptingFunctions.popupAction(PerspectiveScriptingFunctions.java:758) at com.inductiveautomation.perspective.gateway.script.PerspectiveScriptingFunctions.openPopup(PerspectiveScriptingFunctions.java:240) at jdk.internal.reflect.GeneratedMethodAccessor73.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: Page "3075b2e2" not found.
com.inductiveautomation.ignition.common.script.JythonExecException
Traceback (most recent call last):
File "<function:valueChanged>", line 4, in valueChanged
java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: Page "3075b2e2" not found.
I don't think that you need to worry about the pageID in this case. Just call the openPopup() function without it. When it is not defined then the current page is used.
Is the custom property that the change script is on, a session prop?
I agree when I read the documentation for openPopup it says that if I dont identify this then it will open in whatever page I am in. I have tried to not use the pageId and I get an error that says there is no pageId. I think the issue lies somewhere in the fact that I am doing this from a custom session variable but I am not sure why.
Here is the error i get when i take away the pageId:
Traceback (most recent call last):
File "<function:valueChanged>", line 4, in valueChanged
java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: No perspective page attached to this thread.
i am running it simultaneously and changing it from the designer. In the browser if I put in the pageId then the popup does come up fine but i get the error in the logger and the designer.
My point is that the Designer uses a "fake" or "moked" page, and so it doesn't behave the same as what a true session in a browser would.
I would not expect you to need a pageId in the browser at all.
The pageID is only needed if you are attempting to show the pop-up only on a specific page, and that would only matter if you happen to have multiple pages (tabs) open at once, or if you are attempting to open a popup on a remote session.
I created an input field on the screen so i can change this value and I still got an error in the logger. I then went and put back the pagId and no errors and it will open from any page so this seems to work as long as im not running the read write from the Designer.