function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
marcobmarcob 

call Database.executeBatch from @future method allowed?

Hi,

although i've studied the documentation, i can't find the answer to my question: is it allowed to call a batch class from an @future method? Maybe i can't find it because it is simply allowed, but need to be sure, for my entire design is depending on it.

Hope for some respons!

Br, Marco

Best Answer chosen by Admin (Salesforce Developers) 
Shailesh DeshpandeShailesh Deshpande

No you cant call a Batch Class from a future method. Here's the link to support the answer:

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_batch_interface.htm

 

  • Methods declared asfuturearen't allowed in classes that implement theDatabase.Batchableinterface.
  • Methods declared asfuturecan't be called from a batch Apex class.

All Answers

izayizay

The answer to your question is No. If you try to call a batch class from an @future method you get this error.

 

System.AsyncException: Database.executeBatch cannot be called from a batch or future method.

Shailesh DeshpandeShailesh Deshpande

No you cant call a Batch Class from a future method. Here's the link to support the answer:

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_batch_interface.htm

 

  • Methods declared asfuturearen't allowed in classes that implement theDatabase.Batchableinterface.
  • Methods declared asfuturecan't be called from a batch Apex class.
This was selected as the best answer
marcobmarcob

Clear answers, thanks!

Ashish Nigam 39Ashish Nigam 39

Hi  Shailesh Deshpande

There is any alternative to call batch class in future class