I am implementing an interface from where you can update & insert records in SFDC, through a CSV file.

After I process the files accordingly to my specifications, I want to perform an Update and Insert operation over 2 collections, that contain my target records.

What I want to do, is to check the operation result, so the Update Result and Insert Result, through Database.SaveResult object instances. I am interested more in the error scenarios, like for example, this record was not commited in db due to an unknown parent(Parent not found). *For this scenario, sr.getMessage() returns: "Foreign key external ID: [value of Ext ID] not found for field [Ext Id api field name of the Parent] in entity [Api Parent Name]".

I want to know if is there a way to "know" all the possible errors that the getMessage() method, might return, so I can translate them in a mor customizable way.

Thank you guys! Cheers. E.


2 Answers 2



There is also insert, update versions. operationResult classes have .isSuccess() methods (true, false return) along with getErrors().

This means you can look at your error returned from the DB and place your own error in a throw block if you wish


There are multiple reasons for a record to fail on insert/update, and each will have its own unique error message

  • Valdation rule prevents the record from being created/updated with certain field values
  • Unique field constraint on the object and one of the records has a duplicate value on that field
  • The record has a lookup field (an Id in your file) and you don't have access to that record or that object
  • System validation rules, i.e a lead must have a last name or the last name cannot have 600 characters
  • Custom fields marked as required and your record doesn't have a value in that field
  • The record fires a trigger and the trigger throws an unhandled exception (i.e a null value, etc)

You can try to reproduce all these scenarios and see what type of error message is returned, then configure your application accordingly.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .