Sample Code:
Batch Class:
global class CaseEscalation implements Database.Batchable <sObject>{
global Database.QueryLocator start(Database.BatchableContext bc){
String SOQL = ‘SELECT Id, IsEscalated FROM Case WHERE Status = ‘High’ AND IsEscalated = False’;
return Database.getQueryLocator(SOQL);
}
global void execute(Database.BatchableContext bc, List<Case> caseList){
for(Case c : caseList){
c.IsEscalated = true;
}
update caseList;
}
global void finish(Database.BatchableContext bc){
}
}
Batch Class:
global class CaseEscalation implements Database.Batchable <sObject>{
global Database.QueryLocator start(Database.BatchableContext bc){
String SOQL = ‘SELECT Id, IsEscalated FROM Case WHERE Status = ‘High’ AND IsEscalated = False’;
return Database.getQueryLocator(SOQL);
}
global void execute(Database.BatchableContext bc, List<Case> caseList){
for(Case c : caseList){
c.IsEscalated = true;
}
update caseList;
}
global void finish(Database.BatchableContext bc){
}
}
Schedulable Class:
global class CaseEscalationSchedule implements Schedulable{
global void execute(SchedulableContext sc){
CaseEscalation ce = new CaseEscalation();
Database.executeBatch(ce);
}
}