Skip to main content

Notifications

Community site session details

Community site session details

Session Id : VoLmiEO78Cp2uSXf0nvoSv
Power Apps - Building Power Apps
Answered

Custom Error message not displayed in power app

Like (0) ShareShare
ReportReport
Posted on 9 Feb 2023 01:26:19 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:
  • Verified answer
    v-xiaochen-msft Profile Picture
    on 10 Feb 2023 at 03:02:14
    Re: Custom Error message not displayed in power app

    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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,745 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,091 Most Valuable Professional

Leaderboard
Loading started