I want to send a http callout to a external system we are intergrating with.
How do I go about setting up this class so that when a user updates any record, this message is sent out to the external system: "http://{Salesforce}/{RecordId}/{UserId}/{Action}"
where {salesforce} is hardcoded and {Action} is a dml action like update, delete etc.
I am hoping this will be a class that accepts parameters since this needs to be fired whenever a dml action has been done from a number of objects.
Also, I am assuming the method has to be POST
.
Best Answer
This will require triggers and
@future
methods.@future(callout=true)
that accepts the necessary parameters. This method will make the actual callouts.Something to note:
You will likely run into governor limits. A transaction can only make 10 callouts so bulkifying this will be hard unless you can concatenate all of the updates into the body of one message. You could also circumvent this by only making the callout on single record transactions.