What is Database.SaveResult for retrieving all the validation errors?

219    Asked by asutos_8102 in Salesforce , Asked on Aug 24, 2023

 I want to get all the validation error messages from the Apex class to the lightning component. When I got one error message while using DMLException, I tried to use Database.Save result. After the successful update, without any validation error, I get the message that shows successfully updated. But I find nothing in the toast for the records with validation errors. Can anyone help me understand what I am missing out on? 

Answered by Bruce Benedict

 First of all, you can add a default value to confirm that there is no error while dealing with the database. save result. You can also apply try-and-catch blocks to catch any possible error occurring in the code. Using the AuraHandledException can call the error handler on the client side. You can also get this error if you use a DML statement in a for loop.


Your Answer

Interviews

Parent Categories