Delete Records Permanently from Recycle Bin in Salesforce
In Salesforce when we delete any record from an object, it will not be deleted permanently and it will be stored in Recycle Bin till 15 days from the deletion date. The number of records stored in recycle bin depends on Number of User Licenses of the Organisation has pursed and multiply it with 5000 records.
If the number of records in recycle bin crosses this limit Salesforce automatically deletes the old records from Recycle Bin, which are at least in recycle bin for 2 hours. If you want to delete the records permanently from recycle bin before Salesforce deletes it you can use
//To permanently delete the specified records from the recycle bin. Database.emptyRecylebin(List<Id> ids)
//To permanently delete the specified sObject from the recycle bin. Database.emptyRecylebin(sObject sObj)
//To permanently delete the specified list of sObject from the recycle bin. Database.emptyRecylebin(List<sObject> sObjList)
Account acc = new Account(Id='00128000002KuXO'); Database.emptyRecycleBin(acc);
- Maximum number of records per call that we can pass is 200.
- Using this function records deleted can not be undeleted again.
- Theses deleted records from recycle bin can be accessed using the
DataBase.queryAll()for some time typically that would be with in 24 hours or may shorter or longer.