4

Trying to delete records from recyclebin using following code:

List<AsyncLogger__c> deleteList = [SELECT id from AsyncLogger__c WHERE isdeleted = true limit 200 all rows];
List<Id> iDL = new List<Id>();
for(AsyncLogger__c a : deleteList){
    iDL.add(a.id);
}
system.debug(iDL.size());
system.debug(iDL[0]);
Database.emptyRecycleBin(iDL);

I initially tried Database.emptyRecycleBin(deleteList) but after seeing that list<ids> has to be passed, i am getting list of ids and using that.

But records still exist in recyclebin. Is there anything I have to add ?

Scenario: There is a scheduler which checks all cases for closed status and deletes them. But occasionally recycle bin is getting full. So, is there is an option to directly delete record permanently instead of deleting to recycle bin and deleting from there ?(second part, deleting from recycle bin is also not working for me)

Thanks

2
  • Found the solution,... As per SF Documentation, it takes up to 24 hours for compete deletion. Question # 91838 and #4020 here explain more about this behaviour.
    – sf_user
    Commented Sep 26, 2015 at 15:00
  • This is explained here salesforce.stackexchange.com/questions/30647/…
    – PepeFloyd
    Commented Sep 26, 2015 at 16:46

2 Answers 2

2

The Recycle Bin link in the sidebar lets you view and restore recently deleted records for 15 days before they are permanently deleted. Your Recycle Bin record limit is 25 times the Megabytes (MBs) in your storage. For example, if your organization has 1 GB of storage then your limit is 25 times 1000 MB or 25,000 records. If your organization reaches its Recycle Bin limit, Salesforce automatically removes the oldest records if they have been in the Recycle Bin for at least two hours.

Your problem arises because the records have not been hard deleted from the recycle bin. Salesforce runs a process on a scheduled basis that physically deletes records that have been deleted from the recycle bin, if that process has not run yet, you will still see the records there. A fuller description of the behavior of emptyRecycleBin can be found here: Whats the Actual meaning of ALL ROWS in SOQL?

2

As per Salesforce documentation, after records are deleted from the Recycle Bin using emptyRecycleBin call, they can be queried using queryAll() for some time. Typically this time is 24 hours, but may be shorter or longer.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .