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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Save error messages
Power Apps
Unanswered

Save error messages

(0) ShareShare
ReportReport
Posted on by 415

I am trying to collect error messages and save them to a CDS entity so that we can track which users are getting what errors. I've written this code (it's in OnFailure) which DOES save a record to the entity, but the four fields that are supposedly available through the Errors() function just show up with nothing.

 

 

Patch(EST_Errors, Defaults(EST_Errors),
 {
 Errors_Column: First(Errors(EST_Project_Estimates)).Column,
 Errors_Kind: First(Errors(EST_Project_Estimates)).Error,
 Errors_Message: First(Errors(EST_Project_Estimates)).Message,
 Errors_Record: First(Errors(EST_Project_Estimates)).Record.Estimate_Name,
 Errors_Screen: "Estimate Edit"
 }
)

The only one of these 5 fields that has anything in it is the one where I just save the typed string. The fields are all multiline text. There are no errors when running this code. Is there a better way to do this?

 

Categories:
I have the same question (0)
  • Mr-Dang-MSFT Profile Picture
    on at

    @Boneckrh19 ,

    It sounds like you want to write the errors your users are receiving to a CDS entity using the data from the Errors() function.

     

    Since the Errors function returns a table worth of errors, you could use ForAll() to repeat the patch for each potential error.

     

    ForAll(Errors(table_name),
     Patch(EST_Errors, Defaults(EST_Errors),
     {
     Errors_Column: Column,
     Errors_Kind: Error,
     Errors_Message: Message,
     Errors_Record: Name,
     Errors_Screen: "Estimate Edit"
     }
     )
    )

    The benefit is that the ForAll will write the respective column, error, message, so you do not need to use the First() function. This also lets you scale out the statement to capture multiple errors.

  • RBoneck Profile Picture
    415 on at

    Unfortunately the code you provided does not patch any records to my errors entity at all. The code I had did patch an error record on failure, it's just that those four fields were always empty. 

    (As a side note, I don't actually need it to save every error on every save attempt, since that will cause some redundancy.)

  • v-xida-msft Profile Picture
    on at

    Hi @Boneckrh19 ,

    Do you submit your form data using SubmitForm() function?

    Based on the issue that you mentioned, I have made a test on my side, and don't have the issue that you mentioned.

    The screenshot as below:4.JPG

     

    5.JPG

    There are also some known limits with Errors() function. E.G. The Record property within the result the Errors() function returns would be blank when the error occurred during the creation of a record.

    Please check the following article for more details:

    https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-errors#description

     

    I also have made a test on my side (using SubmitForm function to submit form data), and found that the Errors() function could not capture the error message within the Edit form submitted using SubmitForm() function.

    As an fixed solution, please consider take a try to submit your form data into your data source (EST_Project_Estimates) using Patch function instead of SubmitForm() function. Please take a try with the following workaorund:

    Set the OnSelect property of the "Submit" button to following:

    Patch(
     EST_Project_Estimates,
     Defaults(EST_Project_Estimates),
     EditForm1.Updates /* <-- EditFrom1 represents the Edit form control in your app */
    );
    If(
     IsEmplty(Errors(EST_Project_Estimates)),
     Back()
    )

    Set the OnFailure property of the Edit form (EditForm1) to following:

    Patch(
    EST_Errors,
    Defaults(EST_Errors), { Errors_Column: First(Errors(EST_Project_Estimates)).Column, Errors_Kind: First(Errors(EST_Project_Estimates)).Error, Errors_Message: First(Errors(EST_Project_Estimates)).Message, Errors_Record: First(Errors(EST_Project_Estimates)).Record.Estimate_Name, Errors_Screen: "Estimate Edit" } )

    Please take a try with above solution, then check if the issue is solved.

     

    Best regards,

  • Community Power Platform Member Profile Picture
    on at

    Thanks for posting in the community @Boneckrh19. Are you still experiencing this issue? Can you review the above reply and update the thread if it was helpful?

     

    Thank you,

     

    @Anonymous 

  • RBoneck Profile Picture
    415 on at

    This solution patched one record with a message back to my entity the first time I tried it, but then won't patch anything after that. It's not being overridden either, since the modified datetime and the created datetime are the same. Not really sure what happened there.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 840 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 332 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 275

Last 30 days Overall leaderboard