Skip to main content

How to Ask for Confirmation Before an Action in Power Apps

· 5 min read
Jagdish Kumawat
Founder @ Dewiride

Some actions deserve a second thought, such as removing something many people use. Instead of acting at once, the button asks a question on the same screen, with Yes and Cancel below it. Nothing happens until Yes, and screen readers announce the question.

Prerequisites​

  • A button for the action. The example is Remove on the Competency screen of the Career Development Plan app, which takes a competency out of the plan of everyone with a job title (Part 9).
  • A label that announces the question to screen readers (How to Make Screen Readers Announce a Message).

Step 1: Make the Button Ask​

The action button only switches the screen into asking. A context variable says whether it's asking (How to Use Context Variables with UpdateContext):

btnRemoveCS → OnSelect
UpdateContext({locConfirmRemove: true})

The screen's loading formula sets locConfirmRemove back to false, so it never opens in the middle of a question.

While I was building this, the App checker showed a warning under Performance: Unused variable (1) on the screen. The button set locConfirmRemove, but nothing read it yet. It cleared as soon as the question below used it.

Step 2: Show the Question​

The question is a classic label whose Live property is Polite, so screen readers announce it when it appears. Its text is the question while asking and empty otherwise:

lblConfirmCS → Text
If(
locConfirmRemove,
"Remove " & locCompetency.Competency & " from the plan for " & locJobTitle & "? People with this job title won't see it in their plan anymore. Their responses are kept.",
""
)

Say what will happen and to whom. Here, the question names the competency, the job title and what happens to people's responses.

Step 3: Add Yes and Cancel​

The screen already had a row of two buttons for Save and Remove, so I copied that container and pasted it into the body, where it landed at the end, after the question (How to Copy and Paste Controls Between Screens). Then I renamed it and its buttons:

ControlPropertyValue
conConfirmCSVisiblelocConfirmRemove && !locIsLoading
btnConfirmRemoveCSText"Yes, remove"
Icon"Delete"
OnSelectThe action, then Back()
btnCancelRemoveCSText"Cancel"
Icon"Dismiss"
OnSelectUpdateContext({locConfirmRemove: false})

In the example, the action marks the competency inactive with Patch, with IfError around it (How to Remove an Item Without Deleting It).

The Result​

After Remove, the question and the two buttons appear below the action row:

The Edit competency screen for Negotiation with Save and Remove, then the question Remove Negotiation from the plan for Head of Sales? People with this job title won't see it in their plan anymore. Their responses are kept., then Yes, remove and Cancel

Cancel hid both, and nothing was saved. Yes, remove removed the competency, showed Negotiation is removed from the plan for Head of Sales. and went back. On a 360-pixel phone, each pair of buttons shares its row (Fixed: Text and Buttons Cut Off on Narrow Phones):

The same screen at 360 pixels wide with Save and Remove side by side, the question on four lines, and Yes, remove and Cancel side by side

Common Mistakes​

MistakeWhat happensDo this instead
Doing the action in the first buttonOne click removes itThe first button only asks
Hiding the question with VisibleSome screen readers miss itKeep the label visible and change its text
Not resetting the variable when the screen opensThe question is still showing next timeSet it to false in the loading formula

Troubleshooting​

SymptomLikely causeFix
Unused variable under PerformanceThe variable is set but nothing reads it yetFinish the question and the buttons that read it
Yes stays visible after savingThe row's Visible doesn't read the variablelocConfirmRemove && !locIsLoading
The question isn't announcedThe label isn't a live regionUse a classic Label with Live set to Polite

FAQ​

Why not a pop-up?​

A pop-up needs a layer over the screen and a way to move focus into it. In the example, every control sits in a container, and Microsoft's SetFocus reference says it can't set focus to controls in a container. A question in the screen's own flow keeps the reading order and needs no overlay.

Should Yes have the same text as the first button?​

Give it a clearer text, such as Yes, remove, so there aren't two identical buttons on the screen.

Conclusion​

Split the action into a question and an answer: the first button sets a variable, a live label asks, and Yes or Cancel decide. Nothing changes by accident, and everyone hears the question.

Additional Resources​

Stay Updated

Subscribe to our newsletter for the latest tutorials, tech insights, and developer news.

By subscribing, you agree to our privacy policy. Unsubscribe at any time.