Can we call future method from batch class?

556    Asked by AvaBlack in Salesforce , Asked on Mar 2, 2023

 I have a requirement where a future method needs to be called from batch apex.I came across various articles stating that a future method could not be called from the batch. Are there any alternate solutions for that?

Answered by Diya tomar

The answer to your question - can we call future method from batch class is - The general solution to this and other async problems (i.e. unlimited future calls) was proposed with code samples by Dan Appleman at Dreamforce 13. The code can be found at http://advancedapex.com/dreamforce13/ The essence of the solution is to use a custom object to store all async requests and then have a scheduled class launch a batch job to process each async request one-by-one, restarting the scheduled job in the finish() method if there are new async requests created since the batch was started.


Your Answer

Interviews

Parent Categories