Power Apps  

How to Use Confirm function in PowerApps

Introduction

In Microsoft Power Apps, the Confirm() function is used to display a confirmation dialog to the user before performing an action. It helps prevent accidental operations such as deleting data, submitting forms, or resetting inputs.

The function asks the user a question and waits for their response. Based on the response, it returns a Boolean value:

  • true → User clicked Confirm / OK

  • false → User clicked Cancel

This allows your app to conditionally execute actions only when the user agrees.

1. Syntax

Confirm( Message [, Options ] )

Parameters

  • Message

    • Type: Text

    • Description: The message displayed in the confirmation dialog

  • Options (optional)

    • Type: Record

    • Description: Customizes the dialog such as title and button labels

2. Return Value

  • Clicks Confirm / OK → true

  • Clicks Cancel → false

You usually use Confirm() inside an If() function to control what happens next.

3. Simple Example

Confirm before deleting a record

If(
    Confirm("Are you sure you want to delete this record?"),
    Remove(Employees, ThisItem)
)

Explanation

  • Dialog appears with the message.

  • If user clicks OK, the record is removed.

  • If user clicks Cancel, nothing happens.

4. Example: Confirm before submitting a form

If(
    Confirm("Do you want to submit the form?"),
    SubmitForm(Form1)
)

Explanation

  • The form will only submit if the user confirms.

5. Example: Confirm before resetting a form

If(
    Confirm("Reset the form? All unsaved data will be lost."),
    ResetForm(Form1)
)

This prevents users from accidentally losing data.

6. Using Confirm with Options

You can customize the dialog.

Confirm(
    "Do you want to continue?",
    {
        Title: "Confirmation",
        ConfirmButton: "Yes",
        CancelButton: "No"
    }
)

Result

Dialog shows:

  • Title: Confirmation

  • Message: Do you want to continue?

  • Buttons: Yes / No

7. Using Confirm with Variables

Set(
    varConfirm,
    Confirm("Do you want to delete this item?")
);

If(
    varConfirm,
    Remove(Employees, ThisItem)
)

Explanation

  • Result stored in variable varConfirm

  • If true, deletion occurs.

8. Practical Example (Gallery Delete Button)

Suppose you have a Gallery showing employee records.

Delete button OnSelect:

If(
    Confirm("Delete this employee record?"),
    Remove(EmployeeList, ThisItem)
)

User must confirm before the record is removed.

9. Best Practices

✔ Always use Confirm() for destructive actions:

  • Delete record

  • Reset form

  • Cancel transaction

✔ Keep messages clear and short

Example good message:

Are you sure you want to delete this record?

10. Difference Between Confirm and Notify

  • Confirm()

    • Purpose: Ask user for confirmation (Yes/No)

  • Notify()

    • Purpose: Show informational message

Example Notify:

Notify("Record saved successfully")

Summary

Confirm() is used to:

  • Show confirmation dialogs

  • Prevent accidental actions

  • Control app logic based on user decision

Conclusion

In Microsoft Power Apps, the Confirm() function is used to display a confirmation dialog to the user before performing an action. It helps prevent accidental operations like deleting or submitting data. The function returns true if the user confirms and false if the user cancels, allowing the app to execute actions only after user approval.