"No perspective page attached to this thread" when trying to openPopup from Session custom property change

Hi,
I’m trying to open a Popup automatically when a tag goes true.
I’ve tested the openPop from a button and it works fine, but the same code line running from a session custom property change script throws an error.
script:
system.perspective.openPopup(‘fgFgdI8a’, ‘Page/Popups/Recordatorios/TM_Remainder’)
error:
No perspective page attached to this thread

Any suggestions?
Thanks!

For Perspective to open a Popup, it needs to know what Page to open the Popup on. In most places within Perspective, the triggers are from components, which by definition are already part of a Page. Session properties are NOT part of a page, and so even though they are part of a session, there is no direction as to which page they should open on.

That’s why your call is not working. The warning is telling you that the thread on the Gateway which is executing your script has no context as to which page it should open the Popup on. Suppose an active session has five tabs open when this script executes; which tab should the Popup open on?

Workarounds:

  1. (recommended) I’m betting that you actually only want this Popup opened on a single one of your pages, so I would bind a custom property on the root of that View to the session property, and then place your change script on the custom root property instead of the session property. Doing this would result in the popup being opened just as if the change script had been on the session property, but now you will definitely have a Perspective page attached to the thread.

  2. If you absolutely must use a session property to open a Popup, then you have access to the session through the supplied self argument. The following should get you what you need, although it will open a Popup on EVERY page in the session.

for pageId in self.info.pageIds:
    # note that the following call is actually supplying a pageId argument.
    system.perspective.openPopup(‘fgFgdI8a’, ‘Page/Popups/Recordatorios/TM_Remainder’, pageId=pageId)

Makes sense
In my case I do need the Popup to show in any page the user is at (It's a remainder to report pending activities), so I tried option 2 and worked fine
Thanks for the quick reply!

Make sure that you configure a close button for the Popup which iterates through all of the open pages and closes all of the open Popups or you’ll have Popups open on other tabs even after you close the Popup on your current page.

I thought so, but it only opens the Popup once.
If you close the Popup and go to a different page, the Popup does not show

If you're using the code I supplied, and you have multiple pages open, then something is wrong; the code I supplied should open that Popup on every page open in the session.

There is only one page open at any given time, so the Popup shows in the open page.
Thanks!