Post

A Simple Power Apps Pattern for Showing Patch Errors

Diesen Beitrag auf Deutsch lesen

Use the App control OnError property and a global flag to display the exact error message from failed Patch operations.

TL;DR

Set the App control OnError property to mark gblIsError true and notify users with the parsed FirstError.Message. Set gblIsError false immediately before each Patch call so the central error handler can surface failures with a specific message.

Original by Hardit Bhatia, on The Power Addict. Read the original

This is our own summary, not a republication or full translation.

Why it matters

  • Makers: Set gblIsError to false immediately before each Patch call, then rely on the App control OnError formula to surface the returned message to users.
  • Makers: Reuse the central OnError pattern so failed Patch operations set the error flag and display a specific notification instead of leaving users without an explanation.
  • Makers: Review the displayed message during testing because the formula extracts the error text from FirstError.Message for the user notification.

Frequently asked questions

How does the Power Apps App control OnError property handle Patch failures?

Set gblIsError to true in OnError, then notify the parsed FirstError.Message as an error notification.

What should be set before calling Patch in this Power Apps pattern?

Set gblIsError to false before Patch, allowing the App control handler to change it to true when an error occurs.

How does the formula extract the Power Apps error message?

It takes FirstError.Message, splits it at the message marker, removes the closing characters, and displays the resulting text.

This post is licensed under CC BY 4.0 by the author.