UnlockResult Class

The result of a record unlock, returned by a System.Approval.unlock() method.

Approval

The System.Approval.unlock() methods return Approval.UnlockResult objects. Each element in an UnlockResult array corresponds to an element in the ID or sObject array passed as a parameter to an unlock method. The first element in the UnlockResult array corresponds to the first element in the ID or sObject array, the second element corresponds to the second element, and so on. If only one ID or sObject is passed in, the UnlockResult array contains a single element.

The following example shows how to obtain and iterate through the returned Approval.UnlockResult objects. It locks some queried accounts using Approval.unlock 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 for each record. It writes the ID of every record that was processed successfully to the debug log, or writes error messages and failed fields of the failed records.

See Also

The following are methods for UnlockResult.

  • getErrors()

    If an error occurred, returns an array of one or more database error objects, providing the error code and description.

  • getId()

    Returns the ID of the sObject you are trying to unlock.

  • isSuccess()

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

If an error occurred, returns an array of one or more database error objects, providing the error code and description.

public List<Database.Error> getErrors()

Type: List<Database.Error>

Returns the ID of the sObject you are trying to unlock.

public Id getId()

Type: Id

If the field contains a value, the object was unlocked. If the field is empty, the operation was not successfult.

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

public Boolean isSuccess()

Type: Boolean