In Salesforce, the standard approach to delete the records from Recycle bin is to navigate to the Recycle bin, select the records that needs to be deleted, and click Delete to permanently delete them from the org.
There are two other approaches to delete the records from the Recycle bin; the first approach is using Workbench.
In Workbench, the Purge option is used to delete the recycle bin data from salesforce. Below are the steps using Purge option in Workbench to delete the records.
- Log into the Workbench using the Salesforce organization credentials.
- Select Purge Option

- Compose a CSV file with the deleted record ids

Page Break
- Choose the file and click “Next”

- Map the fields and click Confirm Purge button to Purge

The records are purged, and result is shown below

The second approach to delete the records from Recycle bin is using Apex.
In Salesforce apex, the Database class has an emptyRecycleBin() method to permanently delete the specific records from the Recycle Bin. Below are the steps using Apex to delete the records.
- Develop a class using emptyRecycleBin() method.
- Below is the RecyclebinDelete apex class
public class RecyclebinDelete {
public static void deleteRecords(){
account a = new account(name = ‘test universal acc’);
insert a;
system.debug(a);
delete a;
try{
account abc = [select id from account where id=:a.id];
}catch(exception e){
system.debug(‘Account Not Available’);
}
undelete a;
try{
account abc = [select id from account where id=:a.id];
system.debug(abc);
}catch(exception e){
system.debug(‘Account Not Available’);
}
delete a;
database.emptyRecycleBin(a);
system.debug(a);
try{
undelete a;
}catch(exception e){
system.debug(e.getMessage());
}
system.debug(‘end’);
}
}
- Open the Execute anonymous window and use the code below and execute
RecyclebinDelete.deleteRecords();
When the above code is executed, the class is invoked and the emptyRecycleBin() deletes the record permanently from the Recycle Bin.
Below output shows the Debug log where an account record is created, deleted and undeleted.
After undeleting, the record gets restored and is deleted again and the Database.emptyRecycleBin() method is invoked, and the record gets deleted permanently from the recycle bin; so, when the undelete DML is called, it throws the error “UNDELETE_FAILED, Entity is not in the recycle bin”.
