Salesforce | ALL ROWS

Author - Webner

How to get all records of sfobject including records in recycle bin of salesforce and undelete the records?

List objlst = [select id,isdeleted from sfobject ALL ROWS]; //Just add ALL ROWS at the end of SOQL, it retrieves all the records including deleted records in recycle bin:

System.debug('objlst==========' + objlst);
for (sfobject rec: objlst) {
    Database.UndeleteResult result = Database.Undelete(rec, false);
Webner Solutions is a Software Development company focused on developing Insurance Agency Management Systems, Learning Management Systems and Salesforce apps. Contact us at for your Insurance, eLearning and Salesforce applications.

Leave a Reply

Your email address will not be published.