# Button Script & Popup

**URL:** <https://forum.inductiveautomation.com/t/button-script-popup/78600>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [August 31, 2023, 7:52am UTC](https://forum.inductiveautomation.com/t/button-script-popup/78600 "2023-08-31T07:52:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Soundararajans\_S](https://avatars.discourse-cdn.com/v4/letter/s/9f8e36/32.png) [@Soundararajans\_S](https://forum.inductiveautomation.com/u/Soundararajans_S)\
**Post date:** [August 31, 2023, 7:52am UTC](https://forum.inductiveautomation.com/t/button-script-popup/78600/1 "2023-08-31T07:52:18Z")

</div>

Hi,

Main view had one button, to remove the part number from SQL table. Once the button is clicked it will open popup to ask 'Are you sure want to delete' if press 'Yes' the particular record will remove from SQL table and popup need to close.

Here, when pressing 'Yes' button record is not removed, but popup is closed. For popup close am using 'onActionperformed' --\> Popup

before popup my script is there, to remove the record from SQL table.

If script and popup close both are present, record is not removed from SQL table when pressing 'Yes' button.

If popup close option is removed from 'onActionperformed', record is removed from SQL table when pressing 'Yes' button  
 ![1](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/e/6e7a7d8068e7724a0f839bab58997b626f9e5896.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 31, 2023, 7:55am UTC](https://forum.inductiveautomation.com/t/button-script-popup/78600/2 "2023-08-31T07:55:57Z")

</div>

So, is there a question ? What's the issue here ?

If you're just looking for an explanation:  
The actions are not ordered. The popup is likely closed before the script gets a chance to execute.

---

<div class="post-metadata">

**Author:** ![Soundararajans\_S](https://avatars.discourse-cdn.com/v4/letter/s/9f8e36/32.png) [@Soundararajans\_S](https://forum.inductiveautomation.com/u/Soundararajans_S)\
**Post date:** [August 31, 2023, 8:04am UTC](https://forum.inductiveautomation.com/t/button-script-popup/78600/3 "2023-08-31T08:04:01Z")

</div>

without deletion of record, popup is closed. That is my issue.

After removing table record only, need to close popup.

---

<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 31, 2023, 8:04am UTC](https://forum.inductiveautomation.com/t/button-script-popup/78600/4 "2023-08-31T08:04:56Z")

</div>

Close the popup from your script with `system.perspective.closePopup`.

---

<div class="post-metadata">

**Author:** ![Soundararajans\_S](https://avatars.discourse-cdn.com/v4/letter/s/9f8e36/32.png) [@Soundararajans\_S](https://forum.inductiveautomation.com/u/Soundararajans_S)\
**Post date:** [August 31, 2023, 8:11am UTC](https://forum.inductiveautomation.com/t/button-script-popup/78600/5 "2023-08-31T08:11:51Z")

</div>

ya, it's working now.

Thanks.
