Activity › Forums › Salesforce® Discussions › Can i make HTTP Callout from Triggers?
Tagged: Salesforce Apex, Salesforce SOQL
-
Can i make HTTP Callout from Triggers?
Posted by Suraj on April 26, 2017 at 12:21 PMCan i make HTTP Callout from Triggers?
Kirandeep replied 6 years, 2 months ago 5 Members · 4 Replies -
4 Replies
-
Hi Suraj,
Callouts cannot be made from triggers as that would hold up the database transaction until the callout completed, which can be up to 120 seconds from a limits perspective. This could obviously cause significant contention with other transactions and impact performance.
The only way that you can execute a callout from a trigger is to schedule it to run asynchronously, for example by executing a method with the @future method as you have found. The key word here is asynchronously – you can’t wait for a response from the callout as that would require the transaction to stall until it completes, which is the reason that synchronous callouts aren’t allowed.
Thanks.
- [adinserter block='9']
-
Hi Suraj,
Callouts cannot be made from triggers as that would hold up the database transaction until the callout completed, which can be up to 120 seconds from a limits perspective. … Then when the callout completes, the @future method can retrieve the record(s) from the database and update the field(s)
-
only way to execute a callout from a trigger is to run it asynchronously and this can be achieved by executing a method with the @future method.
Log In to reply.