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 understand that when I perform a Database.delete() operation, records will end up in my org's recycle bin. And their presence in the recycle bin is reflected by the IsDeleted field on the object.

But if those records are (for example) scrapes of a web page, they are of little interest to users and I don't want them kicking around in the org. Currently the only way I can see to 'hide' them would be to misuse a Protected (List) Custom Setting object.

From Apex, how can I delete a record and skip this, so it doesn't clutter a user's recycle bin?

share|improve this question
add comment

1 Answer

up vote 7 down vote accepted

Take a look at the Database.emptyRecycleBin(sObject) method or the other variants in the Database class such as Database.emptyRecycleBin(sObject[])

For example, to permanently delete a contact with Id of '003i000000O4xYZ' in the recycle bin:

Contact c = new Contact(Id = '003i000000O4XyZ');
share|improve this answer
Just nipped me to the post on this one Peter! ;-) Also note that there is a couple of other variants of this method. One which takes a list of Id's as well. –  Andrew Fawcett Dec 23 '13 at 13:34
Good point. Updated the answer. Being on xmas vacation I don't have my actual work to get in the way of important things like tending to the SFSE. ;) –  Peter Knolle Dec 23 '13 at 13:39
Thanks @PeterKnolle - missed that! –  user320 Dec 26 '13 at 16:42
add comment

Your Answer


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.