# Perspective button Event Configuration not working

**URL:** <https://forum.inductiveautomation.com/t/perspective-button-event-configuration-not-working/71716>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [March 28, 2023, 4:58pm UTC](https://forum.inductiveautomation.com/t/perspective-button-event-configuration-not-working/71716 "2023-03-28T16:58:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Salem\_Marshall](https://avatars.discourse-cdn.com/v4/letter/s/b38774/32.png) [@Salem\_Marshall](https://forum.inductiveautomation.com/u/Salem_Marshall)\
**Post date:** [March 28, 2023, 4:58pm UTC](https://forum.inductiveautomation.com/t/perspective-button-event-configuration-not-working/71716/1 "2023-03-28T16:58:32Z")

</div>

I am new to Perspective after working in Vision. I have a button on a Perspective popup view that is designed to execute a named query and then close the popup. The named query ("Clear Replacements Table") empties a table in the database.

When I have just the script event configured on the action, it works fine. When I have both the script event and the popup event configured, it closes the view but doesn't run the query. I have tried organizing the actions both ways - once with the script event running first, once with the popup event running first. This did not impact the results.

I attached screenshots of my configurations. Any support would be great! Thank you

**Script event configuration:**

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/1/f133e26274ca78829f23931c537a8fd0ad7c98f6.png)

**Popup event configuration:**

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/a/0a9a3ec0bf5312b649e57f9ec9ac3c19b5a370b3.png)

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [March 28, 2023, 5:40pm UTC](https://forum.inductiveautomation.com/t/perspective-button-event-configuration-not-working/71716/2 "2023-03-28T17:40:10Z")

</div>

I seem to remember this coming up before in the forum.  
Try closing the popup in the script rather than in a separate action.

Tip: remove the Vision tag from your question. It is nothing to do with Vision.

---

<div class="post-metadata">

**Author:** ![jespinmartin1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jespinmartin1/32/57175_2.png) [@jespinmartin1](https://forum.inductiveautomation.com/u/jespinmartin1)\
**Post date:** [March 28, 2023, 5:45pm UTC](https://forum.inductiveautomation.com/t/perspective-button-event-configuration-not-working/71716/3 "2023-03-28T17:45:37Z")

</div>

Assuming "Clear Replacements Table" is the path of your named query:

```auto
system.db.runNamedQuery(system.util.getProjectName(), "Clear Replacements Table" )

```

Remember to Save \*

---

<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:** [March 28, 2023, 5:57pm UTC](https://forum.inductiveautomation.com/t/perspective-button-event-configuration-not-working/71716/4 "2023-03-28T17:57:52Z")

</div>

Actions configured for an Event run asynchronous, so there is no guarantee as to when each will complete. There's a very good chance the closing of the Popup occurs before the query script completes. If you need guaranteed synchronous behaviors, you must put everything into a single script Action.

In general, the only time you should configure multiple Actions off of a single Event is when there is no distinct order in which the Actions begin or complete.

---

<div class="post-metadata">

**Author:** ![Salem\_Marshall](https://avatars.discourse-cdn.com/v4/letter/s/b38774/32.png) [@Salem\_Marshall](https://forum.inductiveautomation.com/u/Salem_Marshall)\
**Post date:** [March 28, 2023, 6:17pm UTC](https://forum.inductiveautomation.com/t/perspective-button-event-configuration-not-working/71716/5 "2023-03-28T18:17:31Z")

</div>

Closing the popup within the script worked. Good to know about the asynchronous timing! (Working code pasted below)

```auto
def runAction(self, event):
	system.db.runNamedQuery("Clear Replacements Table")
	system.perspective.closePopup('')

```
