2

I am trying to execute a callout from trigger. But i got as error in the debug log as

"common.apex.runtime.impl.ExecutionException: Callout from triggers are currently not supported."

I know we can use @future annotation in order to make it asynchronous. But here in my scenario, that must be avoided. So needed as solution to perform callouts from trigger without using @future annotation.

2
  • 4
    AFAIK there is no way to do a callout synchronously from a trigger. There are other ways than future to request the callout from other code (queueables etc.) but it must be asynchronous.
    – Phil W
    Commented Jul 11, 2019 at 7:00
  • 1
    What is the business case here? To Make the callout synchronous? Commented Jul 11, 2019 at 8:19

1 Answer 1

5

You cannot make a synchronous callout from a trigger for the same reason you cannot make a callout after performing DML in the same transaction: the database is stuck holding your transaction open, uncommitted, while it waits for the callout to complete, which could take precious seconds during which records are locked and unavailable.

There is no workaround. You can't do this in a trigger.

If you need to process data via a callout prior to it being committed to your database, override the user interface with a Visualforce page or Lightning component and perform the callout on the front end, prior to performing DML to persist the data.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .