You need to sign in to do that
Don't have an account?
Sanjat Samal 8
How to write a test class for schedule apex class? For Below Code.
global class ClearHistoricalCaseScheduler implements Schedulable
{
global void execute(SchedulableContext SC)
{
System.debug('ClearHistoricalCaseScheduler Start...');
ClearHistoricalCaseBatch batchDelete = new ClearHistoricalCaseBatch();
//Get Clear Date string - 14 months ago
Integer caseDuration = 0 - Integer.valueOf(GenericProjectConfig__c.getValues('MDM_CaseDuration').value__c);
String clearDateString = DateTime.Now().addMonths(caseDuration).formatGmt('yyyy-MM-dd\'T\'HH:mm:ss\'Z\'');
batchDelete.query = 'Select Id From Case Where IsTrueClosed__c = true and OwnerId not in :queueIdSet and CreatedDate < '+ clearDateString ;
ID batchProcessId = Database.executeBatch(batchDelete, 100);
System.debug('Returned Batch Process ID: ' + batchProcessId);
System.debug('ClearHistoricalCaseScheduler Stop...');
}
}
{
global void execute(SchedulableContext SC)
{
System.debug('ClearHistoricalCaseScheduler Start...');
ClearHistoricalCaseBatch batchDelete = new ClearHistoricalCaseBatch();
//Get Clear Date string - 14 months ago
Integer caseDuration = 0 - Integer.valueOf(GenericProjectConfig__c.getValues('MDM_CaseDuration').value__c);
String clearDateString = DateTime.Now().addMonths(caseDuration).formatGmt('yyyy-MM-dd\'T\'HH:mm:ss\'Z\'');
batchDelete.query = 'Select Id From Case Where IsTrueClosed__c = true and OwnerId not in :queueIdSet and CreatedDate < '+ clearDateString ;
ID batchProcessId = Database.executeBatch(batchDelete, 100);
System.debug('Returned Batch Process ID: ' + batchProcessId);
System.debug('ClearHistoricalCaseScheduler Stop...');
}
}
Raj Vakati
Use this code