You need to sign in to do that
Don't have an account?

How to retrieve the error messages added using Sobject.addError()?
I have a list of SObjects. I pass the list to a utility method to check. In the method, it calls addError() of an SObject. How can I retrieve or go through the list and check which item has an error?
Thanks.
The addError() method adds a custom error message to the specific SObject and prevents it from completing the DML operation. And the error message is returned to the user interface or API when the transaction completes. But there is no "getError()" method.
I think you can still accomplish your required error handling by re-factoring the code and how you identify errors.
Thanks, Aalbert.
I am still curious. There must be a way to retrieve the error; otherwise, how can the user interface or API or the DML operation know that an error has occurred?
Anyway, I re-wrote my code to track and return 1st error encountered.