You need to sign in to do that
Don't have an account?
Alper Ozdamar
How can we call a future method from a batch class?
I need to send Asynchronous requests to some 3rd party API and that call method should be @future.
On the other hand, we also want to call this method from Batch class. But Salesforce doesn't allow us to send future method from a batch class?
Any ideas?
On the other hand, we also want to call this method from Batch class. But Salesforce doesn't allow us to send future method from a batch class?
Any ideas?
public String DirectCalloutMethod(...) {
// perform the callout
}
@future
public String FutureCalloutMethod() {
return DirectCalloutMethod();
}
In the batch process use "DirectCalloutMethod" and everywhere else use "FutureCalloutMethod".
All Answers
Greetings!
Unfortunately,you can't call the future method from a batch call as it will throw the error as below:
Future method cant be called from future or Batch
Kindly let me know if it helps you and close your query by marking it as best answer so that it can help others in the future.
Warm Regards,
Shirisha Pathuri
public String DirectCalloutMethod(...) {
// perform the callout
}
@future
public String FutureCalloutMethod() {
return DirectCalloutMethod();
}
In the batch process use "DirectCalloutMethod" and everywhere else use "FutureCalloutMethod".