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

closed as primarily opinion-based by Sebastian Kessel, Jayant Das, David Reed, cropredy, glls Mar 29 at 17:31

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 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 at 16:45
  • This has been asked in one of my interview. – RAT__ Mar 29 at 16:46
  • 1
    Batch and future are both asynchronous, not real-time. – David Reed Mar 29 at 16:48
  • 1
    I read that as "real life", David. But great point – Sebastian Kessel Mar 29 at 16:48
  • @SebastianKessel The answer is "no": you can't call a future method in a batchable context. – sfdcfox Mar 29 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.