1

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.

| improve this question | | | | |
  • 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 Jul 11 '19 at 7:00
  • 1
    What is the business case here? To Make the callout synchronous? – Shailesh Patil Jul 11 '19 at 8:19
2

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.

| improve this answer | | | | |

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.