# 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:** 2

<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:04pm UTC](https://forum.inductiveautomation.com/t/gui-perspective-confirm-cancel-popup/83968/21 "2024-01-09T16:04:28Z")

</div>

Its configured to listen on page scope yes

---

<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:05pm UTC](https://forum.inductiveautomation.com/t/gui-perspective-confirm-cancel-popup/83968/22 "2024-01-09T16:05:03Z")

</div>

Have you checked the logs for any errors?

---

<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:05pm UTC](https://forum.inductiveautomation.com/t/gui-perspective-confirm-cancel-popup/83968/23 "2024-01-09T16:05:56Z")

</div>

The current page is used by default.

---

<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:07pm UTC](https://forum.inductiveautomation.com/t/gui-perspective-confirm-cancel-popup/83968/24 "2024-01-09T16:07:09Z")

</div>

How do I get the pageId of a different page?

---

<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:10pm UTC](https://forum.inductiveautomation.com/t/gui-perspective-confirm-cancel-popup/83968/25 "2024-01-09T16:10:13Z")

</div>

The page id is available in the page props. `{page.props.pageId}` You would need to send it to the popup as a parameter to be used in the `sendMessage()` function.

However, a popup shouldn't change the page, so the current page should be enough to receive the message.

---

<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:11pm UTC](https://forum.inductiveautomation.com/t/gui-perspective-confirm-cancel-popup/83968/26 "2024-01-09T16:11:51Z")

</div>

Thats what Im thinking, is it because my message handler is on the button component?

---

<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:16pm UTC](https://forum.inductiveautomation.com/t/gui-perspective-confirm-cancel-popup/83968/27 "2024-01-09T16:16:52Z")

</div>

So I have view 'EditProduct'. In that view I have a button with message handler 'deleteProductHandler' with code

```auto
def onMessageReceived(self, payload):
	# Get the selected row or rows.
	selRows = self.getSibling('Table').props.selection.data
	
	# Check to see that a row is actually selected.
	if len(selRows) > 0:
	    
	    txID = system.db.beginTransaction(timeout = 10000)
	    # If the user gave confirmation, we need to loop through all of them.
	    for row in selRows:
	             
	        # For each selected row, we need to get the value of the id column in that row.
	        id = row["ProductID"]
	             
	        # Use the id of the row to delete it from the database table.
	        system.db.runNamedQuery("SampleTestV2","Configurations/DeleteProduct", {"ID":id},tx = txID)
	    # commit and close transaction   
	    system.db.commitTransaction(txID)
	    system.db.closeTransaction(txID)
	    self.getSibling("Status").props.text = "Successfully deleted"
	else:
		self.getSibling("Status").props.text = "Error: No row(s) selected"
		

```

The button has onActionPerformed which opens popup view 'ConfirmationPopup'.  
That view has button with code:

```auto
messageType = 'deleteProductHandler'
system.perspective.sendMessage(messageType,{})

```

---

<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:26pm UTC](https://forum.inductiveautomation.com/t/gui-perspective-confirm-cancel-popup/83968/28 "2024-01-09T16:26:09Z")

</div>

How do you know it isn't running?

A few things:

1. You're not doing anything to verify that the query was successful prior to calling commit on the transaction so do you even need a transaction?
2. If you do need a transaction, then you should be using `system.db.beginNamedQueryTransaction()` for use with a Named Query.

I would place a `system.perspective.print("message handled")` as the first line in the script, to verify that the message is being sent and received.

---

<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:27pm UTC](https://forum.inductiveautomation.com/t/gui-perspective-confirm-cancel-popup/83968/29 "2024-01-09T16:27:27Z")

</div>

I have already tried inserting a print statement on the first line. Nothing prints. I use a transaction, so all the deletes go through before deleting.

---

<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:28pm UTC](https://forum.inductiveautomation.com/t/gui-perspective-confirm-cancel-popup/83968/30 "2024-01-09T16:28:50Z")

</div>

I added this

```auto
self.get.Sibling('Status').props.text = "TEXT"

```

So this proves it does not make it to the message handler.

---

<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:29pm UTC](https://forum.inductiveautomation.com/t/gui-perspective-confirm-cancel-popup/83968/31 "2024-01-09T16:29:53Z")

</div>

Are you testing this in a browser or in the designer? There are differences that come into play sometimes.

---

<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:31pm UTC](https://forum.inductiveautomation.com/t/gui-perspective-confirm-cancel-popup/83968/32 "2024-01-09T16:31:00Z")

</div>

The browser of course.

---

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

</div>

I even put a button on the same view with code

```auto
messageType = 'deleteProductHandler'
system.perspective.sendMessage(messageType,{})

```

and nothing happened

---

<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:39pm UTC](https://forum.inductiveautomation.com/t/gui-perspective-confirm-cancel-popup/83968/34 "2024-01-09T16:39:52Z")

</div>

I figured it out

---

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

</div>

One sec Ill tell you exactly what it is in a minute

---

<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:40pm UTC](https://forum.inductiveautomation.com/t/gui-perspective-confirm-cancel-popup/83968/36 "2024-01-09T16:40:52Z")

</div>

The issue is somewhere in my if statement or condition

---

<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:42pm UTC](https://forum.inductiveautomation.com/t/gui-perspective-confirm-cancel-popup/83968/37 "2024-01-09T16:42:11Z")

</div>

> [@HelloWorld](#):
>
> I use a transaction, so all the deletes go through before deleting.

For what its worth, I would just use a filtered delete, and forgo the transaction, if you have no intention of rolling it back for any reason it isn't worth the overhead.

---

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

</div>

It is stopping at TEXT1.1 - It is not running the named query and leaving the loop

```auto
def onMessageReceived(self, payload):
	self.getSibling('Status').props.text = "TEXT"
	# Get the selected row or rows.
	selRows = self.getSibling('Table').props.selection.data
	
	# Check to see that a row is actually selected.
	if len(selRows) > 0:
	    # If the user gave confirmation, we need to loop through all of them.
	    for row in selRows:
	    	self.getSibling('Status').props.text = "TEXT1"
	             
	        # For each selected row, we need to get the value of the id column in that row.
	        id = row["ProductID"]
	        self.getSibling('Status').props.text = "TEXT1.1"
	         
	        # Use the id of the row to delete it from the database table.
	        system.db.runNamedQuery("SampleTestV2","Configurations/DeleteProduct", {"ID":id})
	        self.getSibling('Status').props.text = "TEXT2"
		self.getSibling('Status').props.text = "TEXT3"
	    self.getSibling("Status").props.text = "Successfully deleted"
	else:
		self.getSibling("Status").props.text = "Error: No row(s) selected"
		

```

---

<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:49pm UTC](https://forum.inductiveautomation.com/t/gui-perspective-confirm-cancel-popup/83968/39 "2024-01-09T16:49:44Z")

</div>

Named queries must be different in message handlers because if I copy that code on a button it works and successfully deletes???:?

---

<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:56pm UTC](https://forum.inductiveautomation.com/t/gui-perspective-confirm-cancel-popup/83968/40 "2024-01-09T16:56:19Z")

</div>

I am assuming that "SampleTestV2" is your project name. Try removing that, in theory you shouldn't need it in this scope.

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

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