# Count Numbers of popup open on a view

**URL:** <https://forum.inductiveautomation.com/t/count-numbers-of-popup-open-on-a-view/77274>\
**Category:** Ignition\
**Created:** [August 2, 2023, 9:39am UTC](https://forum.inductiveautomation.com/t/count-numbers-of-popup-open-on-a-view/77274 "2023-08-02T09:39:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sebastien\_ng](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sebastien_ng/32/55297_2.png) [@sebastien\_ng](https://forum.inductiveautomation.com/u/sebastien_ng)\
**Post date:** [August 2, 2023, 9:39am UTC](https://forum.inductiveautomation.com/t/count-numbers-of-popup-open-on-a-view/77274/1 "2023-08-02T09:39:49Z")

</div>

Hello, I have a view where I have many webcams. The PopupId is diferent for each webcam.  
When I click on each webcam, a popup is open. The problem is if I click on 10 webcams, that is mean 10 popup will be open.  
But what client want is: the number of popup that can be open on the screen is 3.  
What does that mean I need count a numbers of popup open before open another popup.

is possible to count the numbers of popup opened?

---

<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:** [August 2, 2023, 11:16am UTC](https://forum.inductiveautomation.com/t/count-numbers-of-popup-open-on-a-view/77274/2 "2023-08-02T11:16:10Z")

</div>

Make wrapper functions around `system.perspective.openPopup` and `system.perspective.closePopup` that increment/decrement or add/remove the popup id on a session custom property, then use that property.

---

<div class="post-metadata">

**Author:** ![sebastien\_ng](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sebastien_ng/32/55297_2.png) [@sebastien\_ng](https://forum.inductiveautomation.com/u/sebastien_ng)\
**Post date:** [August 2, 2023, 12:50pm UTC](https://forum.inductiveautomation.com/t/count-numbers-of-popup-open-on-a-view/77274/3 "2023-08-02T12:50:46Z")

</div>

I initialise a variable varCount on Sessions to increment when I open the popup. But I don't know how can detect event, what close popup to decrment varCount because I haven't define a button to close Popup.  
I close Popup when I click on the **x** of Popup  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/7/f77bc76c16079a2b5b020410f500bc36950d4ffa.png)

---

<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:** [August 2, 2023, 1:42pm UTC](https://forum.inductiveautomation.com/t/count-numbers-of-popup-open-on-a-view/77274/4 "2023-08-02T13:42:31Z")

</div>

Ignition probably keeps a list of open popups ids somewhere, I'm not sure where to find it though...

Maybe they appear in the `pageIds` array you get from `system.perspective.getSessionInfo` ?

---

<div class="post-metadata">

**Author:** ![sebastien\_ng](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sebastien_ng/32/55297_2.png) [@sebastien\_ng](https://forum.inductiveautomation.com/u/sebastien_ng)\
**Post date:** [August 3, 2023, 8:28am UTC](https://forum.inductiveautomation.com/t/count-numbers-of-popup-open-on-a-view/77274/5 "2023-08-03T08:28:22Z")

</div>

Hello, I found the solution:  
I create an CountPopup CUSTON on my SESSION. I initialise it to 0.

when I open popup, CountPopup = CountPopup +1

And I put a script to onShutDown event of my root popup

When Popup is closed , CountPopup = CountPopup -1

it work but I don't know if it is a best solution
