Salesforce | ALL ROWS

|
| By 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);
}

Leave a Reply

Your email address will not be published. Required fields are marked *