Skip to main content
Future Methode and Batch class both are asynchronus but we can call batch class from batch class(In Finish Method) but not future from batch class why??

what is the reason?

Thanks
3 个回答
  1. 2017年7月20日 11:01
    Hi Anu,

    While @Future cannot be called from a batch class, a web service can. A web service can also call a @future method. So have your batch class call an apex web service that in turn calls your @future method.

    There is one trick here. To call your web service from the batch class, you need a session Id. Don't call Userinfo.getsessionid from a scheduled batch class. You won't get a result. Instead, call Userinfo.getsessionId from your schedulable class and pass the id into your batch class as a parameter. Now you have everything you need to call @Future from a batch.

    For more information please check with below links from the community.

    Hope this answers your question.

    Please mark this post as solved if the information helps so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.

    Thanks,

    Nagendra
0/9000