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

**URL:** <https://forum.inductiveautomation.com/t/no-perspective-page-attached-to-this-thread-when-trying-to-openpopup-from-session-custom-property-change/36978>\
**Category:** General Discussion\
**Tags:** perspective\
**Created:** [July 23, 2020, 4:39am UTC](https://forum.inductiveautomation.com/t/no-perspective-page-attached-to-this-thread-when-trying-to-openpopup-from-session-custom-property-change/36978 "2020-07-23T04:39:41Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmorris](https://avatars.discourse-cdn.com/v4/letter/j/ba8739/32.png) [@jmorris](https://forum.inductiveautomation.com/u/jmorris)\
**Post date:** [July 23, 2020, 4:39am UTC](https://forum.inductiveautomation.com/t/no-perspective-page-attached-to-this-thread-when-trying-to-openpopup-from-session-custom-property-change/36978/1 "2020-07-23T04:39:41Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [July 23, 2020, 5:55am UTC](https://forum.inductiveautomation.com/t/no-perspective-page-attached-to-this-thread-when-trying-to-openpopup-from-session-custom-property-change/36978/2 "2020-07-23T05:55:26Z")

</div>

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.

```auto
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)

```

---

<div class="post-metadata">

**Author:** ![jmorris](https://avatars.discourse-cdn.com/v4/letter/j/ba8739/32.png) [@jmorris](https://forum.inductiveautomation.com/u/jmorris)\
**Post date:** [July 23, 2020, 3:15pm UTC](https://forum.inductiveautomation.com/t/no-perspective-page-attached-to-this-thread-when-trying-to-openpopup-from-session-custom-property-change/36978/3 "2020-07-23T15:15:41Z")

</div>

> [@cmallonee](#):
>
> , 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!

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [July 23, 2020, 3:19pm UTC](https://forum.inductiveautomation.com/t/no-perspective-page-attached-to-this-thread-when-trying-to-openpopup-from-session-custom-property-change/36978/4 "2020-07-23T15:19:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jmorris](https://avatars.discourse-cdn.com/v4/letter/j/ba8739/32.png) [@jmorris](https://forum.inductiveautomation.com/u/jmorris)\
**Post date:** [July 23, 2020, 3:50pm UTC](https://forum.inductiveautomation.com/t/no-perspective-page-attached-to-this-thread-when-trying-to-openpopup-from-session-custom-property-change/36978/5 "2020-07-23T15:50:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [July 23, 2020, 3:52pm UTC](https://forum.inductiveautomation.com/t/no-perspective-page-attached-to-this-thread-when-trying-to-openpopup-from-session-custom-property-change/36978/6 "2020-07-23T15:52:20Z")

</div>

> [@jmorris](#):
>
> it only opens the Popup once.

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.

---

<div class="post-metadata">

**Author:** ![jmorris](https://avatars.discourse-cdn.com/v4/letter/j/ba8739/32.png) [@jmorris](https://forum.inductiveautomation.com/u/jmorris)\
**Post date:** [July 23, 2020, 4:29pm UTC](https://forum.inductiveautomation.com/t/no-perspective-page-attached-to-this-thread-when-trying-to-openpopup-from-session-custom-property-change/36978/7 "2020-07-23T16:29:48Z")

</div>

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