You need to sign in to do that
Don't have an account?
moverdorf
Schedule APex Class... Compile error
I am trying to create a scheduled Apex batch job, I created the class below:
global class BatchLoadDaily3 implements Schedulable{
global void execute(SchedulableContext sc) {
// Instantiate batch class
BatchLoadDaily3 bat = new BatchLoadDaily3('','CASCADE');
Database.executeBatch(bat, 20);
}
}
But I am getting an error when I try to save the code:
Error: Compile Error: Constructor not defined: [BatchLoadDaily3].<Constructor>(String, String) at line 5 column 27
Can anyone help me out with the Constructor for this?
Thanks so much in advance!
Hi..
Try below Code...
global class BatchLoadDaily3 implements implements Schedulable{
String query;
global BatchLoadDaily3(){
// Batch Constructor
}
// Start Method
global Database.QueryLocator start(Database.BatchableContext BC){
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<sObject>scope) {
BatchLoadDaily3 bat = new BatchLoadDaily3('','CASCADE');
Database.executeBatch(bat, 20);
}
global void finish(Database.BatchableContext BC){
// Logic to be Executed at finish
}
}
Please accept my answer as a solution if my solution was helpful. This will make it available to others as a proper answer. If you felt that I went above and beyond please give me Kudos by clicking on on the star icon.
Thanks,
Cool Sfdc
well for sure you are doing something wrong with the code. It seems like you self referencing the class name from inside the class