i am calling a batch class from finish method of another batch class and facing the above error
my finish method code is public class BatchPublicCampaignsToGoogle implements Database.Batchable, Database.Stateful, Database.AllowsCallouts {
public void finish(Database.BatchableContext BC){
if(newBatch == true) { CalendarSettings__c c= [Select Id, Name, CalendarId__c,CalendarQuery__c,FieldToDisplay__c from CalendarSettings__c WHERE Name = 'Internal marketing Calendar' LIMIT 1] ; BatchPublicCampaign bjob = new BatchPublicCampaign(); Database.executeBatch(bjob); } }
} but i was facing error Database.executeBatch cannot be called from a batch or future method.
after finishing Batch request i am trying to call it(i have to call it for two times) again.so i call it.
How to get rid of error.i know we can call a batch class from finish method of a Batch Class but why i am getting this error ??