Global Popup error

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:

def runAction(self):
	PageLoaded = self.page.props.pageId
	tagPath = '[default]pageID'
	system.tag.writeBlocking(tagPath, PageLoaded)

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:

def valueChanged(self, previousValue, currentValue, origin, missedEvents):
	CurrentPage = self.custom.CurrentPage
	PopupPath = 'Pages/Menu/SettingMenu'
	system.perspective.openPopup("MyPopup", PopupPath, pageId = CurrentPage)

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.

Please edit your topic to use "Preformatted text" styling on your code and on the error details.

Please see Wiki - how to post code on this forum.

1 Like

Sorry im new to this. Is this better

(emphasis added)

You're attempting to target the PageID as in which Page the Popup should be opened over. However, that Page ID doesn't exist.

Are you trying to open a pop up in a different session? If not, you really do not need the PageID

Essentially I am trying to have this popup come up on any page that I am on when a value changes.

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.

What causes this value to change?

Currently just me changing it in the Tag Browser but eventually it will be driven by a volume change.

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 assume you are running this in the Designer. What happens if you run it in the browser?

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.

Ok so as long as im not in read/write mode on the designer it should be ok?

I believe so, give it a try. If you still get an error, then show what that error is (use the details tab if you can).

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.

I guess the issue here is if I have more than one client open it only opens the popup in the first client.