# system.perspective.openPopup, sessionId Optional but puts logs and error

**URL:** <https://forum.inductiveautomation.com/t/system-perspective-openpopup-sessionid-optional-but-puts-logs-and-error/70436>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [February 28, 2023, 7:45pm UTC](https://forum.inductiveautomation.com/t/system-perspective-openpopup-sessionid-optional-but-puts-logs-and-error/70436 "2023-02-28T19:45:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![edward.fowler](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/edward.fowler/32/24179_2.png) [@edward.fowler](https://forum.inductiveautomation.com/u/edward.fowler)\
**Post date:** [February 28, 2023, 7:45pm UTC](https://forum.inductiveautomation.com/t/system-perspective-openpopup-sessionid-optional-but-puts-logs-and-error/70436/1 "2023-02-28T19:45:20Z")

</div>

Ignition version 8.1.24

> [system.perspective.openPopup - Ignition User Manual 8.1 - Ignition Documentation](https://docs.inductiveautomation.com/display/DOC81/system.perspective.openPopup)

The instructions say the sessionId parameter is optional.

`String sessionId - Identifier of the Session to target. If omitted, the current Session will be used automatically. [optional]`

I executed

`system.perspective.openPopup("Test Popup", 'Test/Popup', showCloseIcon = True)`

The popup doesn't appear and the logs have a dispatcher error:

```auto
Error executing tag event script: Traceback (most recent call last): File "<tagevent:valueChanged>", line 23, in valueChanged at
com.inductiveautomation.perspective.gateway.script.AbstractScriptingFunctions.getSession(AbstractScriptingFunctions.java:104) at
com.inductiveautomation.perspective.gateway.script.AbstractScriptingFunctions.operateOnSession(AbstractScriptingFunctions.java:118) 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
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 session attached to this thread.**

Are the instructions out of date?

Thanks,  
Ted.

---

<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:** [February 28, 2023, 7:55pm UTC](https://forum.inductiveautomation.com/t/system-perspective-openpopup-sessionid-optional-but-puts-logs-and-error/70436/2 "2023-02-28T19:55:40Z")

</div>

The location you're invoking the script from does not have insight into which Perspective Page is invoking the function. This error is typically seen when using openPopup() within Session Events, change scripts of session properties, and Tag change scripts. These areas are not of the "Page" context, and so the invocation has no idea what page to target/use.

The `sessionId` and `pageId` arguments are optional because if omitted they default to the current page. When not running from a Page context, they are no longer optional and you MUST provide the `pageId` you want to target; this informs the back-end which Page thread to utilize. I do not remember if `sessionId` is also required in this same scenario.

---

<div class="post-metadata">

**Author:** ![edward.fowler](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/edward.fowler/32/24179_2.png) [@edward.fowler](https://forum.inductiveautomation.com/u/edward.fowler)\
**Post date:** [February 28, 2023, 8:33pm UTC](https://forum.inductiveautomation.com/t/system-perspective-openpopup-sessionid-optional-but-puts-logs-and-error/70436/3 "2023-02-28T20:33:26Z")

</div>

Ah, that makes sense, thanks @cmallonee.  
I found [Show a popup in perspective on all clients if a value changes - #30 by jlandwerlen](https://forum.inductiveautomation.com/t/show-a-popup-in-perspective-on-all-clients-if-a-value-changes/61133/30) and will dive into it.

This works.

```auto
popupId = "Test Popup"
		viewPath = "Test/Ted/Test Automatic Popup"
		logger = system.util.getLogger("Test Popup")
		logger.info("Testing popups.")
		sessions = system.perspective.getSessionInfo(projectFilter="ProjectX")
		for session in sessions:
			for pageId in session.pageIds:
				# logger.info("{0} | {1}".format(session.id, pageId))
				if currentValue.value:
					try:
						## Wrapped with 'try' because some sessions info productes errors:
						## - java.lang.IllegalArgumentException: Invalid UUID string: 066328F8
						system.perspective.openPopup(popupId, viewPath, sessionId=session.id, pageId=pageId)
					except:
						logger.info("system.perspective.openPopup failed: " + "{0} | {1}".format(session.id, pageId))
				else:
					try:
						## Wrapped with 'try' just incase it produces errors.
						system.perspective.closePopup(popupId, sessionId=session.id, pageId=pageId)
					except:
						logger.info("system.perspective.closePopup failed: " + "{0} | {1}".format(session.id, pageId))

```
