DeleteResult Class

Represents the result of a delete DML operation returned by the Database.delete method.

Database

An array of Database.DeleteResult objects is returned with the delete database method. Each element in the DeleteResult array corresponds to the sObject array passed as the sObject[] parameter in the delete Database method; that is, the first element in the DeleteResult array matches the first element passed in the sObject array, the second element corresponds with the second element, and so on. If only one sObject is passed in, the DeleteResult array contains a single element.

The following example shows how to obtain and iterate through the returned Database.DeleteResult objects. It deletes some queried accounts using Database.delete with a false second parameter to allow partial processing of records on failure. Next, it iterates through the results to determine whether the operation was successful or not for each record. It writes the ID of every record that was processed successfully to the debug log, or error messages and fields of the failed records.

The following are methods for DeleteResult. All are instance methods.

  • getErrors()

    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.

  • getId()

    Returns the ID of the sObject you were trying to delete.

  • isSuccess()

    A Boolean value that is set to true if the DML operation was successful for this object, false otherwise.

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.

public Database.Error[] getErrors()

Type: Database.Error[]

Returns the ID of the sObject you were trying to delete.

public ID getId()

Type: ID

A Boolean value that is set to true if the DML operation was successful for this object, false otherwise.

public Boolean isSuccess()

Type: Boolean