Power Apps error handling Part 2 – displaying error messages

In part 1, we discussed how to create custom error messages in Power Automate and pass them to your canvas app. In this article, let’s see how we can display these error messages with a modern look and feel. Here is the final output:

For this, I am going to use my earlier example – (When we enter the file name, app will get the last modified date. If the name is incorrect, app will display an error message)

Let’s begin..

I am going to break this down to two stages:

  1. Configure “visibility” variable
  2. UI changes
  1. Configure “visibility” variable

So far, we know that we are receiving a custom error message to our canvas app through (flowres.error) variable.

If there is no error message, this variable length should be zero. If there is an error, variable length should be > 0.

Error message box should appear only if (flow.res)=0. Now we have our error prompt visibility logic. Let’s see how we can implement this.

  1. Create a boolean variable(GrayScreenVisible) and set true if error message length =0 and false if length >0.
  2. Add this to button OnSelect action.
  3. Now when you click on the button, app will look at the error message length and determine the value for your boolean variable according to above logic.

Sample Code Snippet

If(Len(flowres.error)=0,Set(GrayScreenVisible, false ),Set(GrayScreenVisible, true ));
Add this code to button OnSelect action

2. UI Changes

Now we need to create the error message prompt.

  1. Drop a rectangle onto the screen, resize it to cover the whole screen and select preferred colour. In this, I have selected purple.
  2. To configure opacity, select “Fill” attribute and set the opacity. (In this, I have set it to 0.7)

3. Now, insert icons, fields, labels to create the error message prompt as needed. Add a cancel button to your prompt as well.

4. Once the design part is done, we need to set the visibility of these components.

5. Select each component and update “Visible” attribute to the boolean “visibility” variable.

6. We need the “Cancel” button to remove the error prompt along with the greyed out box. For this, we need to set the “Visibility” variable(GrayScreenVisible)) to “False” so that all required components will be hidden.

7. Save and publish. Time to test the app..

You can implement error notifications in your canvas apps using the same method. Try designing complex flows, pass multiple error messages and display all necessary information in your applications for better user experience.

Happy Learning!



Categories: Power Automate, PowerApps

Tags: ,

Leave a comment