Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I'm trying to delete certain records from the recycle bin. I am querying the Account records like as:

Map<Id,Account>accMap = new Map<Id,Account>([Select id.name from Account where Type='xyz value' ALL ROWS]);
List<ID> accIds = new List<Id>(accmap.keyset());// Getting correct Ids 
Database.emptyRecycleBin(accIds);
//my account records are successfully deleted from recycle bin

However if i do the same query again then it again showing the same account records.

Can anyone help me why these records are coming out by SOQL but has already been removed from recycle bin.

share|improve this question
    
Can you confirm that there is a delete somewhere in your logic? Assuming there is, the first thing to check would be the results returned by the call that can include error messages as the signature is "Database.EmptyRecycleBinResult[] emptyRecycleBin(ID [] recordIds)". –  Keith C Mar 21 at 12:47
    
Actually records have already been deleted from Objects and that's why present in recycle bin. Now I wanted to remove these records from recycle bin also.But as Salesforce do not provide any such UI to remove some specific records from recycle bin i prefer to use Database.emptyRecycleBin(Id[]). –  userRg Mar 21 at 12:53
1  
Fine, just that your posted code isn't clear as "ALL ROWS" includes non-deleted too. But looks like you have a good answer from @PepeFloyd; pity the API docs don't mention that. –  Keith C Mar 21 at 13:06
    
ALL ROWS looks at soft deleted rows, it is not specifically looking in the recycle bin. You can have soft deleted data that exists, but is not in the recycle bin. –  superfell Mar 21 at 14:57

1 Answer 1

up vote 6 down vote accepted

This is 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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.