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
santhosh  konsanthosh kon 

How to delete inactive accounts by Batch Apex please send me some sample code?

Saikishore Reddy AengareddySaikishore Reddy Aengareddy

global class BatchDeleteInactiveAccounts implements  Database.Batchable<sObject> {

//Modify filter conditions as per your org needs
global string query = 'select Id from Account where Active__c = false';

global Database.QueryLocator start(Database.BatchableContext BC){
 
    return Database.getQueryLocator(query);
}

global void execute(Database.BatchableContext BC, List<sObject> scope){

  Database.delete(scope,false);  

}

global void finish(Database.BatchableContext BC){
}

}