Showing results for 
Search instead for 
Did you mean: 
Frequent Visitor

How to get the error message from Patch function

I am D365FO developer and new to Power apps. Could you please help me to understand the error handle methodology in power apps. I need to extract the error message and display the error details in another screen.


I try to create simple power apps screen using D365FO - VendorGroups as a data source. I have used patch function to create new vendor groups in D365FO. I am able to create new records in D365FO, i tried to handle the errors in powerapps. I have gone through Errors() function to handle the error details in patch function. 


I tried to insert duplicate record and catch the record already exist error message. But Errors().Message function not returning full error message. It is returning only "The request operations is invalid". Could you please help me how to extract the full error message.


I have written below code in patch function

Dropdown2.SelectedText.LegalEntityId <> "Dat",
VendorGroupId: TextInput1.Text,
Description: TextInput2.Text,
Company: Dropdown2.SelectedText.LegalEntityId
"Record could not be registered for Dat company",


In Error screen i have placed the label to get the error message from colErrors() collection. (Refer the attached screenshot)

In Label control (Error Type), text Property used First(colErrors).Error

In Label control (Error details), text Property used First(colErrors).Message


But the actual error message is not captured correctly. Please refer the attached screenshot.


I have verified in collections "colErrors" having only one Error message.


Note: If i use NewForm control, i am able to get the full error message using NewForm.Error function and display in next page. The issue is only with patch function. Please guide me how to extract the error message using patch function



Haribabu V


Community Support
Community Support

Hi @Haribabu ,


The error message of Error function may be generated by the data source or system, we have no way to custom it.

As an alternative workaround, please try to add a Patch function behind the code to modify the Error message.

If you want may face other kinds of error, keep adding other conditions like this:

        First(colErrors).Error=ErrorKind.ConstraintViolated, //Check the error kind
        {Message:"The Detailed Error Message you want"}, // enter custom error message
        First(colErrors).Error = ErrorKind.Conflict,
        {Message: "Conflicts error"}

Test Result:




Thanks for your swift response.

I dont want to customize error message which are generated by Datasource or system. I would like to collect all the error messages and display in my error screen.

When i am using D365FO as datasource in patch function, i am unable to collect the error message.

Hi @Haribabu 

There is nothing wrong with your code and function. In General, the Error message returned from Error function can only get the first main sentence from the full message, this is by design.

What we can do is modify the custom error message or full error message into colErrors collection, as an alternative workaround.


Hi @v-siky-msft ,


In Collection (colErrors) also am getting partial error message. Please refer the attached screenshot.


If i use Formcontrol(EditForm) for same functionality, i can retrieve the full error message on form OnFailure property using EditForm.Error function. Please refer the attached screenshot.


But in my scenario i couldnt use form control so i used Patch function. Could you please help to retrieve full error message from system using Patch function (like form control error message).



Haribabu V

Hi @Haribabu,


Yes, I can get you, since the same thing happened to me when I tested it.

The Message column returned form Error function can only get the first sentence of the full error message, this is by design, I just mentioned. 

'FormName.Error' function is a totally different function from Error() function, though it can get a full error message, but it makes no impact on Error() function.

If you want to get a full error message from Error() function, please submit an idea to PowerApps Idea forums to request the new feature update.

Maybe, you can try the alternative workaround I posted, just replace the full error message to the current short one. This is the way I think it works at the moment


Hi @v-siky-msft ,


Thanks for the update.

I will try to implement the alternative approach. If it is not working for me then i will submit an idea for new feature in powerapps. 

Could you please confirm which one is best approach in powerapps while using D365FO as a data source. It will help me to redesign my powerapps solution.

1. Form control

2. Patch function

Hi @Haribabu,


It depends. EditForm is more convenient, but Patch function is more flexible.


I checked your code that you just want to save three fields to the data source, right?  So, EditForm control is more preferential in your case I think.


Hi @v-siky-msft 


Thanks for the update.I will implement form control for my example.


Actually my understanding is If the screen has single data source fields and there no complex logic i can use Form control. If i have complex logic or some validations/ calculations before inserting the records in the data source i can use Patch function.


my understanding is correct?

Hi @Haribabu ,


Yes! Your understanding is absolutely right!


Helpful resources

October Events

Mark Your Calendars

So many events that are happening this month - don't miss out!

Ignite 2022


Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Top Solution Authors
Top Kudoed Authors
Users online (1,719)