emptyRecycleBin()

Delete records from the recycle bin immediately.

Syntax

EmptyRecycleBinResult[] = connection.emptyRecycleBin(ID[] ids);
                    

Usage

The recycle bin lets you view and restore recently deleted records for 15 days before they are permanently deleted. Your organization can have up to 5,000 records per license in the Recycle Bin at any one time. For example, if your organization has five user licenses, 25,000 records can be stored in the Recycle Bin. If your organization 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:

Sample Code—Java

public void emptyRecycleBin(String[] ids) {
  try {
    EmptyRecycleBinResult[] emptyRecycleBinResults = 
        connection.emptyRecycleBin(ids);
    for (int i = 0; i < emptyRecycleBinResults.length; i++) {
      EmptyRecycleBinResult emptyRecycleBinResult = 
          emptyRecycleBinResults[i];
      if (emptyRecycleBinResult.isSuccess()) {
        System.out.println("Recycled ID: " + 
            emptyRecycleBinResult.getId());
      } else {
        Error[] errors = emptyRecycleBinResult.getErrors();
        if (errors.length > 0)  {
          System.out.println("Error code: " + 
              errors[0].getStatusCode());
          System.out.println("Error message: " + 
              errors[0].getMessage());
        }
      }
    }
  } catch (ConnectionException ce) {
    ce.printStackTrace();
  }
}

Sample Code—C#

/// Demonstrates how to empty the Recycle Bin 
    
public void EmptyRecycleBinSample()
{
   // Create an array of strings to hold the IDs of the records to delete 
    
   string[] ids = new string[] { "00ID0000FooAAE", "00ID0000BarAAE" };
   
   try
   {
       // Delete the records 
    
       binding.delete(ids);
   
       // Empty the records from the Recycle Bin 
    
       // to prevent the records from being undeleted 
    
       EmptyRecycleBinResult[] emptyRecycleBinResults = binding.emptyRecycleBin(ids);
   
       // Process the results 
    
       foreach (EmptyRecycleBinResult emptyRecycleBinResult in emptyRecycleBinResults)
       {
           // Check whether the operation succeeded or had errors 
    
           if (emptyRecycleBinResult.success)
           {
               // Get the ID of the record that we removed 
    
               string recordID = emptyRecycleBinResult.id;
           }
           else
           {
               // Handle the errors. We just print out the first error 
    
               // for demonstration purposes 
    
               Error[] errors = emptyRecycleBinResult.errors;
   
               if (errors.Length > 0)
               {
                   Console.WriteLine("Error code: " + errors[0].statusCode);
                   Console.WriteLine("Error message: " + errors[0].message);
               }
           }
       }
   }
   catch (SoapException e)
   {
       Console.WriteLine(e.Message);
       Console.WriteLine(e.StackTrace);
       Console.WriteLine(e.InnerException);
   }
}

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.

Response

EmptyRecycleBinResult

Faults

InvalidSObjectFault

UnexpectedErrorFault

© Copyright 2000–2012 salesforce.com, inc. All rights reserved.
Various trademarks held by their respective owners.