How to delete the records in sobject that are 3 days old records in Salesforce?

Sample Batch:

global class OldRecordDeleteBatch implements Database.Batchable<sObject> {
    global Database.QueryLocator start(Database.BatchableContext bc) {
        Date threeDaysBefore =;
        String SOQL = 'SELECT Id FROM Employee__c WHERE CreatedDate = : threeDaysBefore';
        return Database.getQueryLocator(SOQL);
    global void execute(Database.BatchableContext bc, List <Employee__c> listEmp) {
        delete listEmp;
    global void finish(Database.BatchableContext bc) {


No comments:

Post a Comment