Newer Version Available

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

emptyRecycleBin()

Delete records from the recycle bin immediately.

Syntax

Usage

The Recycle Bin lets you view and restore recently deleted records for 15 days before they are permanently deleted. Your org can have up to 5,000 records per license in the Recycle Bin at any one time. For example, if your org has five user licenses, 25,000 records can be stored in the Recycle Bin. If your org reaches its Recycle Bin limit, Salesforce automatically removes the oldest records, as long as they have been in the recycle bin for at least two hours.

If you know you will be adding a great number of records to the Recycle Bin and you know you won't need to undelete() them, you may wish to remove them before the Salesforce process deletes records. For example, you can use this call if you are loading a large number of records for testing, or if you are doing a large number of create()calls followed by delete() calls.

Rules and Guidelines

When emptying recycle bins, consider the following rules and guidelines:

  • The logged in user can delete any record that he or she can query in their Recycle Bin, or the recycle bins of any subordinates. If the logged in user has Modify All Data permission, he or she can query and delete records from any Recycle Bin in the organization.
  • Available in version 10.0 and later.
  • Maximum number of records is 200.
  • Do not include the IDs of any records that will be cascade deleted, or an error will occur.
  • Once records are deleted using this call, they cannot be undelete()d.
  • After records are deleted from the Recycle Bin using this call, they can be queried using queryAll() for some time. Typically this time is 24 hours, but may be shorter or longer.

Sample Code—Java

This sample shows how to empty the Recycle Bin. It accepts an array containing the IDs of the records to remove from the Recycle Bin. It calls emptyRecycleBin() and passes it the array of IDs. Next, it iterates over the results and writes the IDs of the removed records or the first error of the failed records to the console.

Sample Code—C#

This sample shows how to empty the Recycle Bin. It accepts an array containing the IDs of the records to remove from the Recycle Bin. It calls emptyRecycleBin() and passes it the array of IDs. Next, it iterates over the results and writes the IDs of the removed records or the first error of the failed records to the console.

Arguments

Name Type Description
ids ID[] Array of one or more IDs associated with the records to delete from the Recycle Bin. Maximum number of records is 200.

UnexpectedErrorFault