How to prompt users with Unsaved form changes warning when user try to exit a Power App

Hello everyone and welcome to my blog. In today’s blog, I will show how you can prompt users if they try to exit app without saving the form.

So let’s get started. For this example, I have used a simple app where I would edit and create new accounts in DataVerse.

My requirement is to show a prompt to the user if the user is exiting the app with unsaved changes on the create or edit form. Let’s see how we do it.

The first and foremost requirement is to understand how can we identify if a form is unsaved. No need to worry here as Microsoft have provided a property “Unsaved” for a form control which will indicate whether a form has any unsaved changes.

If you are not using a form control, you may need to devise your own strategy to identify if the form has unsaved changes or not. Apart from that, for all the other steps mentioned in the blog you can follow verbatim.

But how to understand if a user is trying to exit the app? For this there are couple of properties in the App object.

  • Confirm Exit – Boolean to indicate if a confirmation popup should be shown when user exit the app
  • Confirm exit message – A message to show if the user when they exit the app.

I have set the Confirm Exit property to Unsaved property of the form. I have a single form here for create and edit, but if you have multiple forms, you can write like below.

Editform1.Unsaved Or Createform1.Unsaved

Great! The next step is to show the confirmation message. For that, I set the ConfirmExitMessage property to below.

Save and publish and your changes. And you should be good to go.

Remember you can only test this if you are browsing the app on a native device through Power App mobile app. If you are on browser, your changes your custom message won’t show. Instead you will see the browser’s default unsaved changes prompt.

Hope this helped.

Debajit Dutta


Discover more from Debajit's Power Apps & Dynamics 365 Blog

Subscribe to get the latest posts sent to your email.

Discover more from Debajit's Power Apps & Dynamics 365 Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading