You need to sign in to do that
Don't have an account?
Scheduling Batch Jobs
Hello
I created a very simple schedulable interface that executes a number of Batch jobs.
Is is possible to run additional code only once all batch jobs are complete?
See below.
Thanks a lot in advance
Giorgio
global class iRT_SCHEDULE_Contest implements Schedulable{
global void execute(SchedulableContext SC) {
List<Contest__c> cList = new List<Contest__c>();
cList = [select id from Contest__c];
delete cList;
// We set the size to 20, 50 etc so that the Batch Jobs reset the governor limits every x iterations
iRT_BATCH_Contest actuals = new iRT_BATCH_Contest();
database.executebatch(actuals,1);
>>> CAN I ADD SOME CODE HERE, THAT RUNS ONLY AFTER ALL BATCH JOBS ARE COMPLETE?
}
When you execute a batch it is not mean that is will execute instantly it depent on resource are available or not. First it will stand in queqe then it will execute.
And you write a any code after executing batch statment then that line will execute and not wait for finish the batch first.
So you can write your code in batch class. When batch finish its work then batch execute it own finish() method in last. So you can wirte yourr line of code in finsih() method. IF it helps you than please mark it as a solution and Like it. ENJOY APEX
All Answers
When you execute a batch it is not mean that is will execute instantly it depent on resource are available or not. First it will stand in queqe then it will execute.
And you write a any code after executing batch statment then that line will execute and not wait for finish the batch first.
So you can write your code in batch class. When batch finish its work then batch execute it own finish() method in last. So you can wirte yourr line of code in finsih() method. IF it helps you than please mark it as a solution and Like it. ENJOY APEX
Goodluck!