What does database SaveResult return?

What does database SaveResult return?

SaveResult Methods All are instance methods. If an error occurred, returns an array of one or more database error objects providing the error code and description. If no error occurred, returns an empty set.

Which method would you use to get the errors from database SaveResult after an insert or update operation?

For example, a SaveResult object is returned for insert and update operations. Like all returned results, SaveResult contains a method called getErrors that returns a list of Database. Error objects, representing the errors encountered, if any.

Why does database.saveresult return array of errors?

Each instance of a Database.SaveResult corresponds to a result of a DML operation on a single record. According to the documentation, the method to get error details for a record actually returns an array of Database.Error s instead of a single error. What are the instances when multiple errors occur?

What happens if you use insert in saveresult?

Each element in the SaveResult array corresponds to the sObject array passed as the sObject [] parameter in the Database method. If we use Insert then the partial insert and rollback is not supported. If an error occurs the execution will stop and none of the records will insert into the database.

What does the saveresult object in DML do?

Database.SaveResult [] An array of SaveResult objects contains the result of insert or update DML operation returned by a Database method. Each element in the SaveResult array corresponds to the sObject array passed as the sObject [] parameter in the Database method.

How to get the ID of a record in database.saveresult?

I am using Database.SaveResult and Database.update (…, false) for the very first time and ask myself how to get the Id of the record where a dml has failed. I expected Database.SaveResult.getId ()` to give me that answer but NO…it is empty when the dml failed. Help ;-)!