# 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:** 8\
**Page:** 3

<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:** [January 9, 2024, 4:56pm UTC](https://forum.inductiveautomation.com/t/gui-perspective-confirm-cancel-popup/83968/41 "2024-01-09T16:56:28Z")

</div>

Any error message in your logs ?

> [@HelloWorld](#):
>
> Named queries must be different in message handlers because if I copy that code on a button it works and successfully deletes???:?

Try removing the project name.

As @lrose said, you're using a regular transaction for named queries. Use a namedQueryTransaction.  
But I also agree with him: That's hardly transaction-worthy. If you're never rolling back...  
In this particular case, I'd probably just build the query dynamically and use `runPrepUpdate` just once.

something like

```python
q = """
delete from your_table
where id in ({})
""".format(','.join('?' * len(selRows)))

system.db.runPrepUpdate(q, [product['ProductID'] for product in selRows])

```

Also, don't use `id` as a variable name, it's a built-in identifier. While it may not cause any harm in this situation, I suggest never using built-in names for your own stuff.

---

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

</div>

Weird. Changed code to this

```auto
def onMessageReceived(self, payload):
	self.getSibling("Status").props.text = "TEXT1"
	# 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:	 	             
	        # For each selected row, we need to get the value of the id column in that row.
	        productid = row["ProductID"]
	        self.getSibling("Status").props.text = "TEXT1"
	        # Use the id of the row to delete it from the database table.
	        system.db.runNamedQuery("Configurations/DeleteProduct", {"ID":productid})
	        
	    self.getSibling("Status").props.text = "Successfully deleted"
	else:
		self.getSibling("Status").props.text = "Error: No row(s) selected"
		

```

Printing TEXT1 not executing named query

---

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

</div>

@lrose ^

---

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

</div>

I would almost guarantee that you're getting an error. Look in the gateway logs an see if you have any errors. At this point, it's going to be difficult to help you any further. My guess is that is trying to execute but there is some other issue preventing it.

---

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

</div>

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

</div>

Had an error on trying to delete that specific product. It was being referenced as a foreign key in the database and couldn't be deleted.

---

<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, 6:15pm UTC](https://forum.inductiveautomation.com/t/gui-perspective-confirm-cancel-popup/83968/47 "2024-01-09T18:15:41Z")

</div>

Ok hear me out. Sometimes a product cannot be deleted due to being referenced somewhere. I only want to delete if every elected product can be deleted. Wouldn't that be transaction worthy? Rollback if one fails. Commit if they all pass. Or is there a more worthy way?

---

<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:** [January 9, 2024, 7:00pm UTC](https://forum.inductiveautomation.com/t/gui-perspective-confirm-cancel-popup/83968/48 "2024-01-09T19:00:38Z")

</div>

In this case, yes, but in the code snippet that had the transaction, you were not rolling back.

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