+ Start a Discussion
santhosh  konsanthosh kon 

How to delete old reports by Batch Apex?

Himanshu ParasharHimanshu Parashar
Hi Santhosh,

As I have already specified in your another question you can use following code to delete any records. you need to pass your query only.
 
global class batchAccountUpdate implements Database.Batchable<sObject> {
    global Database.QueryLocator start(Database.BatchableContext BC) {
        String query = 'SELECT Id FROM Report where YOUR_WHERE_CONDITION;
        return Database.getQueryLocator(query);
    }
   
    global void execute(Database.BatchableContext BC, List<Account> scope) {
         delete scope;
    }   
    
    global void finish(Database.BatchableContext BC) {
    }
}

Makes sense ?

Thanks,
Himanshu
Salesforce Certified Developer | Administrator | Service Cloud Consultant

P.S. If my answer helps you to solve your problem please mark it as best answer.