You need to sign in to do that
Don't have an account?
Mat Kwok
Yo dawg, I heard you like Batch Apex
Hi all,
Is it possible to execute another batch apex job in the Finish method of a batch class?
global class SomeBatchJob implements Schedulable, Database.Batchable<SObject> { global void execute(SchedulableContext ctx) { Database.executeBatch(new SomeBatchJob(),1); } global Database.QueryLocator start(Database.BatchableContext ctx) { // Some query } global void execute(Database.BatchableContext ctx, List<SObject> items) { // Operations } global void finish(Database.BatchableContext ctx) { Database.executeBatch(new SomeOtherBatchJob(),1); } }
In essence, I want to be able to daisy-chain 3 schedulable batch jobs, instead of scheduling 3 separate APEX classes. Is this allowed?
I believe a work around is that you can fire Scheduled Apex in the Finish Method.
In the Schedule Apex you could tell it to fire some Batch Apex.
All Answers
I don't think it can be done - you'll have to keep them separate.
That's what I thought. I tried it and it didn't work. Thanks for confirming.
I believe a work around is that you can fire Scheduled Apex in the Finish Method.
In the Schedule Apex you could tell it to fire some Batch Apex.