0

I am trying to understand if there is any real time scenario when we will need to call future method from batch class ?

Can anyone please help me ?

Thanks

  • Can you expand more on why this question is coming up? There are many many many different answers to this question – Sebastian Kessel Mar 29 '19 at 16:45
  • This has been asked in one of my interview. – RAT__ Mar 29 '19 at 16:46
  • 1
    Batch and future are both asynchronous, not real-time. – David Reed Mar 29 '19 at 16:48
  • 1
    I read that as "real life", David. But great point – Sebastian Kessel Mar 29 '19 at 16:48
  • @SebastianKessel The answer is "no": you can't call a future method in a batchable context. – sfdcfox Mar 29 '19 at 17:27
1

No, there's no scenario where you would call a future method in a batchable method. This is because the system does not allow you to do so. If, for some reason, you need another asynchronous call, you must use Queueable. Note that you are limited to just one Queueable per execute method. This is called out in Execution Governors and Limits. Since you mentioned this is for an interview, it's worth studying this document carefully, since many interviewers will ask questions of this nature regarding governor limits.

Not the answer you're looking for? Browse other questions tagged or ask your own question.