Newer Version Available

This content describes an older version of this product. View Latest

undelete()

Undeletes records from the Recycle Bin.

Syntax

Usage

Use this call to restore any deleted record that is undeletable, including those records in the Recycle Bin. Records can be put in the Recycle Bin as the result of a merge() or delete() call. You can identify deleted records, including records deleted as the result of a merge, using the queryAll() call.

You must verify that a record can be undeleted before attempting to delete it. Some records cannot be undeleted, for example, Account records can be undeleted, but not AccountTeamMember records. To verify that a record can be undeleted, check that the value of the undeletable flag in the DescribeSObjectResult for that object is set to true.

Since a delete call cascade-deletes child records, an undelete call undeletes the cascade-deleted records. For example, deleting an account deletes all the contacts associated with that account.

You can undelete records that were deleted as the result of a merge, but the child objects are reparented, which can’t be undone.

Starting with API version 15.0, if you specify a value for a field that contains a string, and the value is too large for the field, the call fails, and an error is returned. In previous versions of the API the value was truncated and the call succeeded. If you wish to keep the old behavior with versions 15.0 and later, use the AllowFieldTruncationHeader SOAP header.

Note

This call supports the AllOrNoneHeader, AllowFieldTruncationHeader, and CallOptions headers.

Rollback on Error

The AllOrNoneHeader header allows you to roll back all changes unless all records are processed successfully. This header is available in API version 20.0 and later. Lets a call roll back all changes unless all records are processed successfully.

Sample Code—Java

This sample calls queryAll() to get the last five deleted accounts. It then passes the IDs of these accounts to undelete(), which restores these accounts. Finally, it checks the results of the call and writes the IDs of the restored accounts or any errors to the console.

Sample Code—C#

This sample calls queryAll() to get the last five deleted accounts. It then passes the IDs of these accounts to undelete(), which restores these accounts. Finally, it checks the results of the call and writes the IDs of the restored accounts or any errors to the console.

Arguments

Name Type Description
ids ID[] IDs of the records to be restored.

Response

UndeleteResult