Error:
Method does not exist or incorrect signature: void schedule(String, String, BatchEmail) from the type System
I am trying to write a scheduler class which runs every 60 days. I am getting the error above when I try saving it. Not sure what the problem is.
Here is the code:
global class BatchEmails_Scheduler implements Schedulable {
public static String sc = '0 0 18 1/60 * ? *';
global static String schedule() {
BatchEmails be = new BatchEmails();
return system.schedule('Send Emails', sc, be);
}
global void execute(SchedulableContext sc) {
BatchEmails be1 = new BatchEmails();
ID batchprocessid = database.executeBatch(be1, 100);
}
}
Best Answer
You are trying to pass a
Batchable
implementation whereSchedulable
is expected. This is just one reason why it is better to roll both into the same class. Regardless, yourschedule
method should pass in an instance ofBatchEmails_Scheduler
:Typically, rolling them together reduces the number of classes you have to maintain and adds little overhead: