After batch 1 is complete in the finish() method this calls startNewBatch() in GeneralUtils which fires the newbacth batch class
However, running this you will see an error
Database.executeBatch cannot be called from a batch or future method.
global class batch l implements Database.Batchable<sObject>, Database.Stateful{
global Database.QueryLocator start(Database.BatchableContext BC){
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC,
List<sObject> scope){
}
global void finish(Database.BatchableContext BC){
GeneralUtils.startNewBatch();
}
public class GeneralUtils{
public static void startNewBatch(){
newbacth batchable = new newbacth();
Id newbacthID = Database.executeBatch(batchable);
}
}
Hi Steve,
ReplyDeleteInteresting problem. Did you ever encounter a decent solution? I was thinking of using time-based workflow to handle the batch-to-batch call..
In the last release they were talking about allowing batches calling batches
ReplyDeleteBut it isnt released yet
ReplyDelete