# Close popup automatically

**URL:** <https://forum.inductiveautomation.com/t/close-popup-automatically/43199>\
**Category:** Ignition\
**Created:** [February 9, 2021, 6:24pm UTC](https://forum.inductiveautomation.com/t/close-popup-automatically/43199 "2021-02-09T18:24:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![michael.black](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@michael.black](https://forum.inductiveautomation.com/u/michael.black)\
**Post date:** [February 9, 2021, 6:24pm UTC](https://forum.inductiveautomation.com/t/close-popup-automatically/43199/1 "2021-02-09T18:24:36Z")

</div>

Using perspective, I have a popup that comes up. It is in the Views folder with the actual popup view in Popups/NavDropdown. It is a navigation popup that comes up and I want to automatically close the popup once they press one of the navigation buttons. It is not working. What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![michael.black](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@michael.black](https://forum.inductiveautomation.com/u/michael.black)\
**Post date:** [February 9, 2021, 6:26pm UTC](https://forum.inductiveautomation.com/t/close-popup-automatically/43199/2 "2021-02-09T18:26:24Z")

</div>

![screenshot1](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/b/bbc2edb8a4355a7f2bc32f79c720d3004a0d7df6.jpeg) ![screenshot2](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/9/c9bfb4263942cbbda8b42c08addbdda79950f38c.jpeg)

---

<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 9, 2021, 6:59pm UTC](https://forum.inductiveautomation.com/t/close-popup-automatically/43199/3 "2021-02-09T18:59:19Z")

</div>

You shouldn’t mix Actions which are dependent on timing, because all of the attached actions for an Event are run asynchronously - meaning they can start/complete out of order (or maybe not at all if a reference to the page is pulled out form underneath them).

Regardless, the issue stems from your use of `closePopup`. That [function](https://docs.inductiveautomation.com/display/DOC81/system.perspective.closePopup) requires the id of a popup if you’re targeting a specific popup, but it can also accept an empty string if you just want to close the most recently opened Popup.

So you have two options in your current Script:  
A. Instead of supplying the viewPath in use, you need to specify the identifier of the popup which is displaying your navigation buttons.  
B. Instead of supplying the viewPath in use, you need to supply an empty string (`""`).

If you want to supply the identifier, you should look at the Popup action you used to open the popup (the identifier field is half-way down and to the left):

 ![Screen Shot 2021-02-09 at 10.56.10AM](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/5/754ed09d8a6ef70ef6b0fe64129d08000c360919.png)

Or if you used a script, then you want the `id` argument you supplied:

```auto
system.perspective.openPopup(id='ThisIsTheValueYouWant', view='Popups/NavDropdown')

```

---

<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:** [February 10, 2021, 12:05pm UTC](https://forum.inductiveautomation.com/t/close-popup-automatically/43199/4 "2021-02-10T12:05:29Z")

</div>

Related question: can you read the popup’s id once it’s open? I’ve been writing the popup id into a popup param in order to use it to close the popup, but wondering if there’s a cleaner way?

---

<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 10, 2021, 3:15pm UTC](https://forum.inductiveautomation.com/t/close-popup-automatically/43199/5 "2021-02-10T15:15:51Z")

</div>

> [@nminchin](#):
>
> I’ve been writing the popup id into a popup param in order to use it to close the popup, but wondering if there’s a cleaner way?

No, this is absolutely the way I personally recommend. If you haven't been doing that and only have an idea that a Popup is open but no way to identify it, then you should use the empty string option.
