# Dropdown confirmation not working?

**URL:** <https://forum.inductiveautomation.com/t/dropdown-confirmation-not-working/5485>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [November 28, 2012, 1:30am UTC](https://forum.inductiveautomation.com/t/dropdown-confirmation-not-working/5485 "2012-11-28T01:30:26Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![scott\_stc](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@scott\_stc](https://forum.inductiveautomation.com/u/scott_stc)\
**Post date:** [November 28, 2012, 1:30am UTC](https://forum.inductiveautomation.com/t/dropdown-confirmation-not-working/5485/1 "2012-11-28T01:30:26Z")

</div>

Will someone double-check me on this: When a dropdown component has the comfirmation enabled, and during runtime the user selects NO in the confirmation box, the event will not change the tag or property it would have changed if the user had chosen YES...., but it does change the selectedValue and selectedString. So, the user selects NO, and correctly the event doesn't trigger, but the list still shows the selected string and the selectedValue also changes, even though the user selected NO.

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [November 28, 2012, 1:49am UTC](https://forum.inductiveautomation.com/t/dropdown-confirmation-not-working/5485/2 "2012-11-28T01:49:22Z")

</div>

The dropdown component doesn’t have built-in confirmation. Are you doing confirmation in an event handler (script)? Are you using a different component?

---

<div class="post-metadata">

**Author:** ![scott\_stc](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@scott\_stc](https://forum.inductiveautomation.com/u/scott_stc)\
**Post date:** [November 28, 2012, 7:51pm UTC](https://forum.inductiveautomation.com/t/dropdown-confirmation-not-working/5485/3 "2012-11-28T19:51:40Z")

</div>

We are doing it in the Event handler, on a Property change. (We specify a change in the selectedValue).

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [November 28, 2012, 10:03pm UTC](https://forum.inductiveautomation.com/t/dropdown-confirmation-not-working/5485/4 "2012-11-28T22:03:03Z")

</div>

In that case the value will update regardless of whether or not the user selects yes or no. If you change the value back it will run the propertyChange script again.

---

<div class="post-metadata">

**Author:** ![scott\_stc](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@scott\_stc](https://forum.inductiveautomation.com/u/scott_stc)\
**Post date:** [November 29, 2012, 3:16am UTC](https://forum.inductiveautomation.com/t/dropdown-confirmation-not-working/5485/5 "2012-11-29T03:16:07Z")

</div>

Yes, we tried that too, with that exact result. How can we get it to not change if the operator selects NO on the confirmation?

---

<div class="post-metadata">

**Author:** ![James.Lorenz](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/james.lorenz/32/3290_2.png) [@James.Lorenz](https://forum.inductiveautomation.com/u/James.Lorenz)\
**Post date:** [November 29, 2012, 6:17pm UTC](https://forum.inductiveautomation.com/t/dropdown-confirmation-not-working/5485/6 "2012-11-29T18:17:15Z")

</div>

What you can do is throw in a boolean variable to handle the case where the user selects “NO”, which will fire another propertyChange event since the selectedValue/selectedLabel/etc will be changed back to its original value. Try creating a script module under the app package called “test” and add this script to the module. Then you can reference it from the event handler of the dropdown with app.test.confirm(event).

[code]global flag  
flag = 0

def confirm(event):  
import system  
global flag  
if event.propertyName == “selectedLabel” and not flag:  
if not system.gui.confirm(“Are you sure?”):  
event.source.selectedLabel = event.oldValue  
flag = 1

```
elif event.propertyName == "selectedLabel" and flag:
	flag = 0

```

[/code]

---

<div class="post-metadata">

**Author:** ![scott\_stc](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@scott\_stc](https://forum.inductiveautomation.com/u/scott_stc)\
**Post date:** [December 1, 2012, 7:45pm UTC](https://forum.inductiveautomation.com/t/dropdown-confirmation-not-working/5485/7 "2012-12-01T19:45:01Z")

</div>

James, Thank you for the help and code. We implemented your suggestion, and it worked fantastically! Thanks again 😃

---

<div class="post-metadata">

**Author:** ![jeroen.werkbrouck](https://avatars.discourse-cdn.com/v4/letter/j/c89c15/32.png) [@jeroen.werkbrouck](https://forum.inductiveautomation.com/u/jeroen.werkbrouck)\
**Post date:** [November 28, 2022, 2:14pm UTC](https://forum.inductiveautomation.com/t/dropdown-confirmation-not-working/5485/8 "2022-11-28T14:14:59Z")

</div>

What I found to do with a dropdown is as follows:

- make a custom property integer 'valueConfirmed'  
Connect your tag bidirectional with that property.
- Connect your tag not bidirectional with the 'selected value'

And then in propertyChange of the dropdown following code:

```python
if event.propertyName == "selectedValue" and event.source.valueConfirmed != event.newValue:
	title = "Change dropdown value."
	message = "Are u sure you want to change te value to " + event.source.selectedStringValue
	
	if system.gui.confirm(message,title):
		event.source.valueConfirmed = event.newValue
	else:
		event.source.selectedValue = event.oldValue

```

And so everything can be in the same component.

---

<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:** [November 28, 2022, 2:49pm UTC](https://forum.inductiveautomation.com/t/dropdown-confirmation-not-working/5485/9 "2022-11-28T14:49:32Z")

</div>

I recommend never using the `system.gui.*` popups. They are poison for event handling in your UI.

Use the technique you describe to enable a separate "Save" button to handle the situation correctly. I use an additional "Dirty" custom property to style fields that have changes. Some discussions of this:

[https://forum.inductiveautomation.com/search?q=%40pturmel%20raw%20dirty](https://forum.inductiveautomation.com/search?q=%40pturmel%20raw%20dirty)
