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
Preetham ThummalaPreetham Thummala 

future

Can we call future method from finish method of Batch Apex?
Best Answer chosen by Preetham Thummala
NagaNaga (Salesforce Developers) 
Hi Preetham,


The maximum time out you can specify for a HTTP request is 120sec(default is 10), so you'll need to decide if the services that you are using are feasable to work in that time limit...You can always handle random api call time outs using try - catch block, but if you think that the service that you are using would almost for every call out need more time then I'm afraid you'll need to look for a better solution as Batch apex approach would not work in your case.
For your Ref: http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_callouts_timeouts.htm

I suggest give a try putting the callout logic in execute() method as 120 sec is massive time and majority of the services give you response a few seconds.

https://developer.salesforce.com/forums/?id=906F0000000AqdVIAS

Best Regards
Naga Kiran
 

All Answers

NagaNaga (Salesforce Developers) 
Hi Preetham,


The maximum time out you can specify for a HTTP request is 120sec(default is 10), so you'll need to decide if the services that you are using are feasable to work in that time limit...You can always handle random api call time outs using try - catch block, but if you think that the service that you are using would almost for every call out need more time then I'm afraid you'll need to look for a better solution as Batch apex approach would not work in your case.
For your Ref: http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_callouts_timeouts.htm

I suggest give a try putting the callout logic in execute() method as 120 sec is massive time and majority of the services give you response a few seconds.

https://developer.salesforce.com/forums/?id=906F0000000AqdVIAS

Best Regards
Naga Kiran
 
This was selected as the best answer
Vivek DeshmaneVivek Deshmane
Hi Preetham,

First, you can't call a future method from a Batch class.  My guess is that the threads generated from batches are considered "future" methods, so trying to do it results in the "FATAL_ERROR System.LimitException: Too many future calls: 1" error.

Regards,
-Vivek​

 
atla satheeshkumaratla satheeshkumar
Hi Preetham,

we can't call a future method from a Batch class due to salesforce Limitation.

Regards
Satish Atla
GarryPGarryP
Answer is No.
Reason : Future and Batch apex both are and asynchronous call. And salesforce does not allow chaining of asynchronous call.