web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Custom Error message n...
Power Apps
Answered

Custom Error message not displayed in power app

(0) ShareShare
ReportReport
Posted on by 111

Hi

I'm trying to display a custom error message if a Patch() fails. It's not displaying my text but just the standard message. Please see my code below. I have turned on formula error processing in setting for the app. Any clues? 

Thanks for any insights 😊

 

If(

    nErrorCount < 1,

    Patch(

        'DocuLibrary',

        LookUp(

            'DocuLibrary',

            ID = glbSelectedDocID

        ),

        {

            'Sign Off Status': "In Progress",

            ExpectedApprovalCount: nApproverCnt,

            ApprovalRequester: CompUser.Email,

            'Approved by Date': DateValue(dteApprovedByDatePicker.SelectedDate)

        }

    );

    //if it fails display error, try again

    If(

        !IsEmpty(Errors('DocuLibrary')),

        Set(Msg0, $"{First(Errors('DocuLibrary')).Message}");

        Notify(

            Concat(

                Errors('DocuLibrary'),

                Msg0 & " - Failed to update document for workflow, please try again."

            ),

            NotificationType.Error

        );

, //else, update approval history list

      ….stuff here…..

); //end of update code

Categories:
I have the same question (0)
  • Verified answer
    v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    Hi @Flyingfishnm ,

     

    Please try this:
    1\ Use

    If(
    
     nErrorCount < 1,
    
     Patch(
    
     'DocuLibrary',
    
     LookUp(
    
     'DocuLibrary',
    
     ID = glbSelectedDocID
    
     ),
    
     {
    
     'Sign Off Status': "In Progress",
    
     ExpectedApprovalCount: nApproverCnt,
    
     ApprovalRequester: CompUser.Email,
    
     'Approved by Date': DateValue(dteApprovedByDatePicker.SelectedDate)
    
     }
    
     );
    
     //if it fails display error, try again
    
     If(
    
     IsEmpty(Errors('DocuLibrary')),
    
     
    
     // update approval history list
    
     ….stuff here…..
    
    ); //end of update code

     

    Besides, set the onError property of app to:

    Set(Msg0,$"{First(Errors('DocuLibrary')).Message}");Error(Concat(Errors('DocuLibrary'),Msg0&" - Failed to update document for workflow, please try again."))

     

    Best Regards,

    Wearsky

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 834

#2
Valantis Profile Picture

Valantis 533

#3
Haque Profile Picture

Haque 410

Last 30 days Overall leaderboard