function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
StellarStellar 

Where could I get information of the records deleted from the recycle bin?

Hi there,

I am trying to retrieve all records only in the recycle bin, and I learnt from the forum that they can be selected by IsDeleted=true, but the problem is that those records hard delected from the recycle bin (which means they actually do not exist in the org any more) are still marked as IsDeleted=true.

Could any expert help find a way to rule them out? Or would anyone know the object name of the recycle bin if there is one?

Many thanks and best regards,
Stellar 
Best Answer chosen by Stellar
SandhyaSandhya (Salesforce Developers) 
Hi Stellar,


It is possible to hard delete using DataBase.emptyRecycleBin method in the Batch class. Create a sample Batch class as mentioned below and use DataBase.emptyRecycleBin method in the Batch class.
 
global class BatchDeletion implements Database.Batchable<sObject>, Schedulable{   
    global BatchDeletion(){}

    global Database.QueryLocator start(Database.BatchableContext bc){
        return Database.getQueryLocator([Select id from Account where Name='Test Account12']);
    } 

    //Execute method for the Schedulable interface
    global void execute(SchedulableContext sc){   
        //execute the batch
        BatchDeletion deleteCS = new BatchDeletion();
        ID batchprocessid = Database.executeBatch(deleteCS);
    }

    //Execute method for the batchable interface
    global void execute(Database.BatchableContext BC, list<sObject> scope){     
        delete scope;   
        DataBase.emptyRecycleBin(scope); 
    }

    global void finish(Database.BatchableContext BC){}
}

Please refer below link for more information.

http://salesforce.stackexchange.com/questions/22875/how-do-i-delete-records-in-the-recycle-bin

Please accept my solution as Best Answer if my answer was helpful. It will make it available for other as the proper solution. If you felt I went above and beyond, you can give me kudos.
 
Thanks and Regards
Sandhya

 

All Answers

Ashwani PradhanAshwani Pradhan
This is not feasible if record is not available in recycle bin(keep only for 15 days). You have to raise case with SF and they can provide from their archive.
Vasani ParthVasani Parth
Stellar,

This blog  (http://www.asagarwal.com/762/how-to-recover-data-undelete-undo-in-salesforce) will help you reach your destination. 
VineetKumarVineetKumar
You can use ALL ROWS to query records in your organization's Recycle Bin.
Also, you cannot use the ALL ROWS keywords with the FOR UPDATE keywords.
SandhyaSandhya (Salesforce Developers) 
Hi Stellar,


It is possible to hard delete using DataBase.emptyRecycleBin method in the Batch class. Create a sample Batch class as mentioned below and use DataBase.emptyRecycleBin method in the Batch class.
 
global class BatchDeletion implements Database.Batchable<sObject>, Schedulable{   
    global BatchDeletion(){}

    global Database.QueryLocator start(Database.BatchableContext bc){
        return Database.getQueryLocator([Select id from Account where Name='Test Account12']);
    } 

    //Execute method for the Schedulable interface
    global void execute(SchedulableContext sc){   
        //execute the batch
        BatchDeletion deleteCS = new BatchDeletion();
        ID batchprocessid = Database.executeBatch(deleteCS);
    }

    //Execute method for the batchable interface
    global void execute(Database.BatchableContext BC, list<sObject> scope){     
        delete scope;   
        DataBase.emptyRecycleBin(scope); 
    }

    global void finish(Database.BatchableContext BC){}
}

Please refer below link for more information.

http://salesforce.stackexchange.com/questions/22875/how-do-i-delete-records-in-the-recycle-bin

Please accept my solution as Best Answer if my answer was helpful. It will make it available for other as the proper solution. If you felt I went above and beyond, you can give me kudos.
 
Thanks and Regards
Sandhya

 
This was selected as the best answer
StellarStellar
Thank you guys, but I am sorry that no one actually answered my question. I might have confused you, but my purpose is to get a sync with the recycle bin, which includes all the soft deleted records = all deleted records - those emptied from the recycle bin.

Or Can I get information on which records are hard deleted? I only need their ids, instead of restoring them.

Thanks anyway.

Best regards,
Stellar