Activity Forums Salesforce® Discussions Can i make HTTP Callout from Triggers?

  • Manpreet

    Member
    April 26, 2017 at 1:22 pm

    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.

  • Pooja

    Member
    February 27, 2020 at 2:24 pm

    You cannot make a HTTP callout from triggers.

  • Aditya

    Member
    February 27, 2020 at 3:48 pm

    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)

  • Kirandeep

    Member
    February 27, 2020 at 4:15 pm

    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.

Popular Salesforce Blogs