# Show a popup in perspective on all clients if a value changes

**URL:** <https://forum.inductiveautomation.com/t/show-a-popup-in-perspective-on-all-clients-if-a-value-changes/61133>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [June 23, 2022, 7:25pm UTC](https://forum.inductiveautomation.com/t/show-a-popup-in-perspective-on-all-clients-if-a-value-changes/61133 "2022-06-23T19:25:11Z")\
**Posts on this page:** 11\
**Page:** 3

<div class="post-metadata">

**Author:** ![Alagumani\_Kaliyaperu](https://avatars.discourse-cdn.com/v4/letter/a/8baadc/32.png) [@Alagumani\_Kaliyaperu](https://forum.inductiveautomation.com/u/Alagumani_Kaliyaperu)\
**Post date:** [September 7, 2022, 1:56am UTC](https://forum.inductiveautomation.com/t/show-a-popup-in-perspective-on-all-clients-if-a-value-changes/61133/42 "2022-09-07T01:56:08Z")

</div>

Hi all Thanks. Actually i want open the Emergency pop-up when my integer value equal to 4. As I mentioned earlier I couldn’t make it work with my OPC address. So wrote the Script on OPC integer tag to control the memory Boolean address.

```auto
if currentValue.value==4:
		system.tag.writeBlocking(["[.]../../prcd_potr_002/New Tag1"],[True])
	else:
		system.tag.writeBlocking(["[.]../../prcd_potr_002/New Tag1"],[False])

```

Below is memory address code

```auto
popupId = "O2Alarm"
	viewPath = "EquipmentView/Emergency_Stop1" # insert your view path here
	logger = system.util.getLogger("POPUP")
	sessions = system.perspective.getSessionInfo()
	for session in sessions:
		for pageId in session.pageIds:
			logger.info("{0} | {1}".format(session.id, pageId))
	
			if currentValue and currentValue.value: # I added an additional safety check for first time use here
				system.perspective.openPopup(popupId, viewPath, sessionId=session.id, pageId=pageId)
				logger.info("openPopup complete")
			else:
				# note no viewPath arg
				system.perspective.closePopup(popupId, sessionId=session.id, pageId=pageId)

```

Actually the session I mentioned in earlier conversation is about Designer Sessions. we are three people parallelly working for same project.  
In browser session it’s working fine i tried it with multiple sessions.

---

<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:** [September 7, 2022, 5:34am UTC](https://forum.inductiveautomation.com/t/show-a-popup-in-perspective-on-all-clients-if-a-value-changes/61133/43 "2022-09-07T05:34:24Z")

</div>

Anything that requires a page context in Perspective will not work in the Designer. This list of features which do not work in the Designer includes - but is not limited to - Docked View actions/scripts, Popup actions/scripts, and Navigation actions/scripts.

This is because the Designer “session” does not contain a Page in the traditional sense. We “mock-up” some data for the relevant properties (like `self.page.props.id`), but while you’re in the Designer you are only ever looking at a View.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [September 7, 2022, 7:27am UTC](https://forum.inductiveautomation.com/t/show-a-popup-in-perspective-on-all-clients-if-a-value-changes/61133/44 "2022-09-07T07:27:14Z")

</div>

> [@Alagumani\_Kaliyaperu](#):
>
> ```auto
> if currentValue.value==4:
> system.tag.writeBlocking(["[.]../../prcd_potr_002/New Tag1"],[True])
> else:
> system.tag.writeBlocking(["[.]../../prcd_potr_002/New Tag1"],[False])
> 
> ```

Just a quick aside about a little bit of code.  
This won't change anything in the functionality, but I'd suggest writing it like this:

```python
open_popup = currentValue.value == 4
system.tag.writeBlocking(["[.]../../prcd_potr_002/New Tag1"], [open_popup])

```

Everytime you're using an `if/else` statement to define if something is `True` or `False`, remember the condition is itself already a boolean.  
It's all about the readability - while removing the `if/else` might reduce branching, I'm sure the interpreter is already smart enough to do this itself. So if you find the `if/else` version clearer or more readable, then keep using it.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 7, 2022, 12:44pm UTC](https://forum.inductiveautomation.com/t/show-a-popup-in-perspective-on-all-clients-if-a-value-changes/61133/45 "2022-09-07T12:44:12Z")

</div>

> [@pascal.fragnoud](#):
>
> I’m sure the interpreter is already smart enough to do this itself.

No, it's not. Code simplicity matters for performance.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [September 7, 2022, 12:46pm UTC](https://forum.inductiveautomation.com/t/show-a-popup-in-perspective-on-all-clients-if-a-value-changes/61133/46 "2022-09-07T12:46:07Z")

</div>

Really ? Is that just Jython, or is Cpython not smart enough either ?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 7, 2022, 1:04pm UTC](https://forum.inductiveautomation.com/t/show-a-popup-in-perspective-on-all-clients-if-a-value-changes/61133/47 "2022-09-07T13:04:36Z")

</div>

Python3 might be smart enough. Jython uses the same source to `.pyc` bytecode compiler as CPython2. Last I looked, it wasn’t smart enough.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [September 7, 2022, 2:24pm UTC](https://forum.inductiveautomation.com/t/show-a-popup-in-perspective-on-all-clients-if-a-value-changes/61133/48 "2022-09-07T14:24:18Z")

</div>

I don’t think Python, Jython, or Java for that matter really do _any_ optimizations in the compiler. Python for simplicity, Java because it relies on the JVM to do runtime optimizations of code. As someone who frequently has to debug or reverse engineer things, I really appreciate it 🙂

---

<div class="post-metadata">

**Author:** ![wakatipu](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wakatipu/32/70339_2.png) [@wakatipu](https://forum.inductiveautomation.com/u/wakatipu)\
**Post date:** [December 2, 2022, 2:05am UTC](https://forum.inductiveautomation.com/t/show-a-popup-in-perspective-on-all-clients-if-a-value-changes/61133/49 "2022-12-02T02:05:33Z")

</div>

In my case, I found that if I had a designer open, the popup would not open on any session at all. (On Ignition Edge designer 8.1.22, if that is relevant). I just made a slight adjustment to the code to get it running on my end, even when a designer is open:

```auto
def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
	popupId = "SomeUniqueValue"
	viewPath = "PopupViews/SmallPopup" # insert your view path here
	logger = system.util.getLogger("POPUP")
	sessions = system.perspective.getSessionInfo()
	for session in sessions:
		for pageId in session.pageIds:
			logger.info("{0} | {1}".format(session.id, pageId))
			if session.userAgent != "<designer>":
				if currentValue.value:
					system.perspective.openPopup(popupId, viewPath, sessionId=session.id, pageId=pageId)
				else:
					# note no viewPath arg
					system.perspective.closePopup(popupId, sessionId=session.id, pageId=pageId)

```

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [December 2, 2022, 7:29am UTC](https://forum.inductiveautomation.com/t/show-a-popup-in-perspective-on-all-clients-if-a-value-changes/61133/50 "2022-12-02T07:29:22Z")

</div>

If I had to take a guess, I'd say that since the designer can't open a popup, trying to do so raises an error and aborts the rest of the code. If the designer is the first one to be processed, nothing else get processed, and the sessions don't get their popups.

Now let's wait for Phil or Paul to tell me how wrong I am 😃

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [December 2, 2022, 10:13am UTC](https://forum.inductiveautomation.com/t/show-a-popup-in-perspective-on-all-clients-if-a-value-changes/61133/51 "2022-12-02T10:13:16Z")

</div>

> [@pascal.fragnoud](#):
>
> wait for Phil or Paul

Huh. No clue.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [July 28, 2023, 3:21am UTC](https://forum.inductiveautomation.com/t/show-a-popup-in-perspective-on-all-clients-if-a-value-changes/61133/52 "2023-07-28T03:21:32Z")

</div>

fyi, I found, at least while trying to use this on a session custom prop on change script, that I needed to use this to get the session's id field:

```auto
session.info.id

```

instead of just

```auto
session.id

```

[Previous page](https://forum.inductiveautomation.com/t/show-a-popup-in-perspective-on-all-clients-if-a-value-changes/61133.md?page=2)
