I have a scheduled class which needs to call to external WebService. Base on the WebService result - I'll need to run some logic - and call to additional update callout function.

Since the callout are not supported in scudeule classes - solution would be to use @future annotation.

The problem is that I can't tell when the first WebService function finish it's execution and I can't use it's output.

Is there any way call the WebService as well use its output result?


You'll have to do whatever DML you need to do in the future/queueable method that you call. You cannot perform a callout in a Schedulable class. That means your logic will look like this:

public void execute(SchedulableContext context) {
@future(callouts=true) public static void callWebService() {
  ... Do callout and DML ...

The future method will run after the Schedulable class' execute method, so there's no way your Schedulable class can use the results of your callout method.

  • Thanks, I was happier if I could avoid pushing DML objects, but as I see it I have no other option. – aralele Jun 18 '18 at 6:55
  • @aralele Yes, that's correct. It's an unfortunate limit of the system, but that's the best you can do. – sfdcfox Jun 18 '18 at 8:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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