0

I've looked around to try to find some posts on this and there are many but none that address my specific question (that I could find).

I am trying to call a @Future method inside a for loop in my trigger class from Batch. I tried Queueable/WebService and I don't know why but I am not getting expected result.

1st issue: I have a method let say FutureMethod which is a @Future method and we can't call @Future from a batch.

2nd issue: The FutureMethod does a callout, so the method must be @Future as callouts from triggers are not allowed.

Please suggest me the way or Alternate way to solve this problem.

3
  • use Queuable apex.
    – Mahmood
    Mar 18 '20 at 13:09
  • 2
    Personally I think you have 3 issues. The first is calling a @future method from a loop in general. You are bound to encounter 1 or more platform limits using such a design. From what I can tell, Queuable is the apex feature you should work towards, see Dan Applemans video. You could also review some answers on Calling future method from Batch
    – TSmith
    Mar 18 '20 at 13:17
  • You can't call multiple Queueables from a batch either. You need to either set your batch size to one or find a way to bulkify the endpoint you are calling, in addition to any move to Queueable. Please note, however, that you can call out synchronously from a batch.
    – Adrian Larson
    Mar 18 '20 at 15:31

Your Answer

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

Browse other questions tagged or ask your own question.