# GUI - Perspective - Confirm / Cancel popup

**URL:** <https://forum.inductiveautomation.com/t/gui-perspective-confirm-cancel-popup/83968>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [January 9, 2024, 2:21pm UTC](https://forum.inductiveautomation.com/t/gui-perspective-confirm-cancel-popup/83968 "2024-01-09T14:21:08Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![HelloWorld](https://avatars.discourse-cdn.com/v4/letter/h/b782af/32.png) [@HelloWorld](https://forum.inductiveautomation.com/u/HelloWorld)\
**Post date:** [January 9, 2024, 2:21pm UTC](https://forum.inductiveautomation.com/t/gui-perspective-confirm-cancel-popup/83968/1 "2024-01-09T14:21:08Z")

</div>

I am working in perspective and wondering if there is a way to mimic this in perspective. I have a delete button and want to have user confirmation before deleting.

```auto
# If a row is selected, ask for confirmation before deleting the rows.
    if system.gui.confirm("Are you sure you want to delete " + str(len(selRows)) + " row(s)?", "Are You Sure?", 0):

```

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [January 9, 2024, 2:26pm UTC](https://forum.inductiveautomation.com/t/gui-perspective-confirm-cancel-popup/83968/2 "2024-01-09T14:26:24Z")

</div>

There are multiple ways to implement this, depending on the structure of the rest of your project. The easiest is probably a popup. When the button is clicked, display a popup, on the popup, when the confirmation button is clicked use `system.perspective.sendMessage()` to send a message to a message handler on the view which can then run the delete operation.

I would recommend writing all of your CRUD operations in a script module as pure functions which can then be called from multiple places in the project.

---

<div class="post-metadata">

**Author:** ![HelloWorld](https://avatars.discourse-cdn.com/v4/letter/h/b782af/32.png) [@HelloWorld](https://forum.inductiveautomation.com/u/HelloWorld)\
**Post date:** [January 9, 2024, 2:27pm UTC](https://forum.inductiveautomation.com/t/gui-perspective-confirm-cancel-popup/83968/3 "2024-01-09T14:27:49Z")

</div>

I have the Delete as a named query.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [January 9, 2024, 2:29pm UTC](https://forum.inductiveautomation.com/t/gui-perspective-confirm-cancel-popup/83968/4 "2024-01-09T14:29:33Z")

</div>

Sure, doesn't really change much. You still need to call the named query, and the view is going to have all of that information readily available. Better not to pass the values around needlessly, just ask for confirmation and then execute only with given that confirmation.

---

<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 9, 2024, 2:31pm UTC](https://forum.inductiveautomation.com/t/gui-perspective-confirm-cancel-popup/83968/5 "2024-01-09T14:31:15Z")

</div>

In case it isn't clear, there's no way to do this in a **single** script.

---

<div class="post-metadata">

**Author:** ![HelloWorld](https://avatars.discourse-cdn.com/v4/letter/h/b782af/32.png) [@HelloWorld](https://forum.inductiveautomation.com/u/HelloWorld)\
**Post date:** [January 9, 2024, 2:31pm UTC](https://forum.inductiveautomation.com/t/gui-perspective-confirm-cancel-popup/83968/6 "2024-01-09T14:31:33Z")

</div>

So just do a popup in the delete button script and if confirm is chosen in the popup, send a message to message handler on the delete button component and run the named query ?

---

<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 9, 2024, 2:33pm UTC](https://forum.inductiveautomation.com/t/gui-perspective-confirm-cancel-popup/83968/7 "2024-01-09T14:33:57Z")

</div>

Yes, just like that. If you want to make a generic popup button for this kind of duty, parameterize not just the content to display, but also the message handler name, scope, and perhaps a unique key to include in the payload. This makes the message targeting and reception handling very robust.

---

<div class="post-metadata">

**Author:** ![HelloWorld](https://avatars.discourse-cdn.com/v4/letter/h/b782af/32.png) [@HelloWorld](https://forum.inductiveautomation.com/u/HelloWorld)\
**Post date:** [January 9, 2024, 2:45pm UTC](https://forum.inductiveautomation.com/t/gui-perspective-confirm-cancel-popup/83968/8 "2024-01-09T14:45:17Z")

</div>

When the message handler says, "This method will be called when a message with the matching type code arrives at this component". Is 'type code' the value entered in for 'Message Type'.

---

<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 9, 2024, 2:46pm UTC](https://forum.inductiveautomation.com/t/gui-perspective-confirm-cancel-popup/83968/9 "2024-01-09T14:46:35Z")

</div>

Yes. I like to think of this as the handler's name.

---

<div class="post-metadata">

**Author:** ![HelloWorld](https://avatars.discourse-cdn.com/v4/letter/h/b782af/32.png) [@HelloWorld](https://forum.inductiveautomation.com/u/HelloWorld)\
**Post date:** [January 9, 2024, 2:58pm UTC](https://forum.inductiveautomation.com/t/gui-perspective-confirm-cancel-popup/83968/10 "2024-01-09T14:58:35Z")

</div>

Which listen scope would make most sense if I am opening a popup when the delete button is hit? Session, Page, or View?

---

<div class="post-metadata">

**Author:** ![YF129701](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yf129701/32/60498_2.png) [@YF129701](https://forum.inductiveautomation.com/u/YF129701)\
**Post date:** [January 9, 2024, 3:32pm UTC](https://forum.inductiveautomation.com/t/gui-perspective-confirm-cancel-popup/83968/11 "2024-01-09T15:32:42Z")

</div>

What about using the One-Shot button? I've been using them in a lot of places in place of normal buttons because it gives you confirmation options and the script you define only runs if the user hits the "Yes" or "Confirm" button. I know I'm derailing the conversation but wanted to bring up another option that I love to use.

---

<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 9, 2024, 3:36pm UTC](https://forum.inductiveautomation.com/t/gui-perspective-confirm-cancel-popup/83968/12 "2024-01-09T15:36:43Z")

</div>

> [@HelloWorld](#):
>
> scope would make most sense

I would expect you to need page scope.

---

<div class="post-metadata">

**Author:** ![HelloWorld](https://avatars.discourse-cdn.com/v4/letter/h/b782af/32.png) [@HelloWorld](https://forum.inductiveautomation.com/u/HelloWorld)\
**Post date:** [January 9, 2024, 3:40pm UTC](https://forum.inductiveautomation.com/t/gui-perspective-confirm-cancel-popup/83968/13 "2024-01-09T15:40:45Z")

</div>

Hmm. I see there is a require confirm one shot button.

---

<div class="post-metadata">

**Author:** ![HelloWorld](https://avatars.discourse-cdn.com/v4/letter/h/b782af/32.png) [@HelloWorld](https://forum.inductiveautomation.com/u/HelloWorld)\
**Post date:** [January 9, 2024, 3:55pm UTC](https://forum.inductiveautomation.com/t/gui-perspective-confirm-cancel-popup/83968/14 "2024-01-09T15:55:00Z")

</div>

I have deleteProductHandler Message Handler on my delete button. My delete button onActionPerformed opens popup with a confirm button with code

```auto
def runAction(self, event):
	messageType = 'deleteProductHandler'
	system.perspective.sendMessage(messageType) 

```

Nothing is happening. The code inside the messageHandler is not running.

---

<div class="post-metadata">

**Author:** ![HelloWorld](https://avatars.discourse-cdn.com/v4/letter/h/b782af/32.png) [@HelloWorld](https://forum.inductiveautomation.com/u/HelloWorld)\
**Post date:** [January 9, 2024, 3:57pm UTC](https://forum.inductiveautomation.com/t/gui-perspective-confirm-cancel-popup/83968/15 "2024-01-09T15:57:21Z")

</div>

How does it know where to send the message. The handler is on a component in a different view.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [January 9, 2024, 4:01pm UTC](https://forum.inductiveautomation.com/t/gui-perspective-confirm-cancel-popup/83968/16 "2024-01-09T16:01:13Z")

</div>

Page scope is used by default if the scope parameter isn't supplied.

You must provide a payload, even if it is just an empty dictionary.

```python
def runAction(self, event):
	messageType = 'deleteProductHandler'
	system.perspective.sendMessage(messageType,{})

```

[https://docs.inductiveautomation.com/display/DOC81/system.perspective.sendMessage](https://docs.inductiveautomation.com/display/DOC81/system.perspective.sendMessage)

---

<div class="post-metadata">

**Author:** ![HelloWorld](https://avatars.discourse-cdn.com/v4/letter/h/b782af/32.png) [@HelloWorld](https://forum.inductiveautomation.com/u/HelloWorld)\
**Post date:** [January 9, 2024, 4:02pm UTC](https://forum.inductiveautomation.com/t/gui-perspective-confirm-cancel-popup/83968/17 "2024-01-09T16:02:50Z")

</div>

That did not fix the issue, but ok that's good to know.

---

<div class="post-metadata">

**Author:** ![HelloWorld](https://avatars.discourse-cdn.com/v4/letter/h/b782af/32.png) [@HelloWorld](https://forum.inductiveautomation.com/u/HelloWorld)\
**Post date:** [January 9, 2024, 4:03pm UTC](https://forum.inductiveautomation.com/t/gui-perspective-confirm-cancel-popup/83968/18 "2024-01-09T16:03:21Z")

</div>

I think its because the message handler is configured on a different view

---

<div class="post-metadata">

**Author:** ![HelloWorld](https://avatars.discourse-cdn.com/v4/letter/h/b782af/32.png) [@HelloWorld](https://forum.inductiveautomation.com/u/HelloWorld)\
**Post date:** [January 9, 2024, 4:03pm UTC](https://forum.inductiveautomation.com/t/gui-perspective-confirm-cancel-popup/83968/19 "2024-01-09T16:03:53Z")

</div>

I need to add a pageid i believe

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [January 9, 2024, 4:04pm UTC](https://forum.inductiveautomation.com/t/gui-perspective-confirm-cancel-popup/83968/20 "2024-01-09T16:04:00Z")

</div>

Is the message handler configured to listen on page scope?

[Next page](https://forum.inductiveautomation.com/t/gui-perspective-confirm-cancel-popup/83968.md?page=2)
