Deleting a Single Item From the Recycle Bin

Sometimes you just want to remove a single item or a subset of items from the recycle bin without emptying the entire thing. I found this long-standing idea on IdeaExchange, and then realized I could do it in Apex.

First step is to find the Id of the record you want deleted from the recycle bin. I use workbench to create my SOQL query and query deleted items. Be sure to select the option to include deleted and archived records. Here’s a query to get the IDs of deleted cases.

select id from case where isdeleted = true

Once I have the ID, then I can use workbench to execute anonymous Apex. Just put a comma separated list of Ids in the List:

Database.emptyRecycleBin(new List<Id> {'500U000000IonltIAB'});

Leave a Reply