You need to sign in to do that
Don't have an account?
Sharmila Sahu 20
I have created a schedular class but it is not showing while trying to schedule it through UI
I have created a schedular class but it is not showing while trying to schedule it through UI.
Please find below batch and schedular class :
Batch Class:
public class deletePendingServiceReq implements Database.Batchable<sObject>{
public static Date lastYear = Date.today().addMonths(-10);
public static string statusVal='Pending';
public Database.QueryLocator start(Database.BatchableContext context)
{
return Database.getQueryLocator('Select ID,createdDate,MUSW__Status__c from MUSW__Application2__c where CreatedDate < :lastYear and MUSW__Status__c=:statusVal');
}
public void execute(Database.BatchableContext context, List<SObject> records)
{
//System.debug('records to be deleted'+records);
delete records;
}
public void finish(Database.BatchableContext BC){}
}
Schedular:
public class deletePendingServiceReqSchedular implements Schedulable {
public void execute(SchedulableContext ctx)
{
Database.executeBatch(new deletePendingServiceReq());
}
}
It is working if I am scheduling it through developer console:
System.schedule('Scheduled Job 1', '0 54 * * * ?', new deletePendingServiceReqSchedular());
But it is not showing in list of schedulable class when I am trying to schedule it through UI.
I am system admin.
SetUp-->Apex Class-->Schedule Class
Please find below batch and schedular class :
Batch Class:
public class deletePendingServiceReq implements Database.Batchable<sObject>{
public static Date lastYear = Date.today().addMonths(-10);
public static string statusVal='Pending';
public Database.QueryLocator start(Database.BatchableContext context)
{
return Database.getQueryLocator('Select ID,createdDate,MUSW__Status__c from MUSW__Application2__c where CreatedDate < :lastYear and MUSW__Status__c=:statusVal');
}
public void execute(Database.BatchableContext context, List<SObject> records)
{
//System.debug('records to be deleted'+records);
delete records;
}
public void finish(Database.BatchableContext BC){}
}
Schedular:
public class deletePendingServiceReqSchedular implements Schedulable {
public void execute(SchedulableContext ctx)
{
Database.executeBatch(new deletePendingServiceReq());
}
}
It is working if I am scheduling it through developer console:
System.schedule('Scheduled Job 1', '0 54 * * * ?', new deletePendingServiceReqSchedular());
But it is not showing in list of schedulable class when I am trying to schedule it through UI.
I am system admin.
SetUp-->Apex Class-->Schedule Class
Try this
Go to Develop-> Apex Classes and click on Compile all classes, then click on Schedule Apex and you will be able to schedule the job.
Regards,
Uttpal Chandra