# Vision: One Shot button Confirm message access

**URL:** <https://forum.inductiveautomation.com/t/vision-one-shot-button-confirm-message-access/84849>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [January 27, 2024, 6:28pm UTC](https://forum.inductiveautomation.com/t/vision-one-shot-button-confirm-message-access/84849 "2024-01-27T18:28:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jacque\_trahan](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jacque_trahan/32/58886_2.png) [@jacque\_trahan](https://forum.inductiveautomation.com/u/jacque_trahan)\
**Post date:** [January 27, 2024, 6:28pm UTC](https://forum.inductiveautomation.com/t/vision-one-shot-button-confirm-message-access/84849/1 "2024-01-27T18:28:28Z")

</div>

I am having an issue with this in vision. I have a script on the actionPerformed, and it fired no matter what the user picks for the confirm message "Are you sure".  
I might be missing something but I could not find out how to run a script only if user selected yes for a vision one stop button's confirm property being turn to True, and wait for a use choice.

That said I am trying this workaround it but can not figure out how to access the users choice for that confirm question:

My thought process is something like this but this only grabs if the confirm property is selected right now. Is there a way to grab the users answer via script?

```auto
if event.source.confirm == True:
	do the thing

```

---

<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:** [January 27, 2024, 6:32pm UTC](https://forum.inductiveautomation.com/t/vision-one-shot-button-confirm-message-access/84849/2 "2024-01-27T18:32:01Z")

</div>

The user's choice is the return value from that function. Please show your code so we can be more specific with our advice.

---

<div class="post-metadata">

**Author:** ![jacque\_trahan](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jacque_trahan/32/58886_2.png) [@jacque\_trahan](https://forum.inductiveautomation.com/u/jacque_trahan)\
**Post date:** [January 27, 2024, 6:34pm UTC](https://forum.inductiveautomation.com/t/vision-one-shot-button-confirm-message-access/84849/3 "2024-01-27T18:34:48Z")

</div>

My code is on the actionPerformed. It runs once the button is clicked and does not wait for the confirm choice.

```auto
Task_ID = event.source.parent.getComponent('Power Table').Task_ID
if event.source.confirm == True: # but look for the user choice
	system.db.runNamedQuery('myQuery', {'prams':Task_ID })

```

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

---

<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:** [January 27, 2024, 6:35pm UTC](https://forum.inductiveautomation.com/t/vision-one-shot-button-confirm-message-access/84849/4 "2024-01-27T18:35:43Z")

</div>

Where is your call to `system.gui.confirm()` ? That isn't optional.

---

<div class="post-metadata">

**Author:** ![jacque\_trahan](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jacque_trahan/32/58886_2.png) [@jacque\_trahan](https://forum.inductiveautomation.com/u/jacque_trahan)\
**Post date:** [January 27, 2024, 6:39pm UTC](https://forum.inductiveautomation.com/t/vision-one-shot-button-confirm-message-access/84849/5 "2024-01-27T18:39:29Z")

</div>

Ah so I need to make my own gui...I can do that

.From the one [shot button doc](https://docs.inductiveautomation.com/display/DOC81/Vision+-+One-Shot+Button) I was under the impression nothing will work until the confirm choice that is built in pops up. Then if the user choices "Yes" then it does the thing, and "No" nothing happens.

If this is the case ill just make a regular button to do all this, and delete the on shot button.

**Edit.**

I kept the one shot button, turned off the confirm property or it'll pop up twice if you do not, and this is my final code:

```auto
Task_ID = event.source.parent.getComponent('Power Table').Task_ID

useChoice = system.gui.confirm("Are You Sure")

if useChoice: 
	system.db.runNamedQuery('QueryPath', {'pram':Task_ID })

```

---

<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:** [January 27, 2024, 6:59pm UTC](https://forum.inductiveautomation.com/t/vision-one-shot-button-confirm-message-access/84849/6 "2024-01-27T18:59:30Z")

</div>

Ah, it turns out I've never used the one-shot button or it's built-in confirm function. I would expect that the `actionPerformed` script would simply not be run at all if that built-in confirmation was rejected.

I strongly recommend not using `system.gui.confirm()`, nor its popup peers. They block the entire GUI while open. Instead, use a two-stage confirmation with ordinary buttons, and possibly timers. Where a 1st button enables a 2nd button, possibly for a limited time, or until the 2nd button is clicked. No further confirmation needed.
