You need to sign in to do that
Don't have an account?
Anil Ganivada 4
Callout on apex trigger before insert
Hi,
I need to make a callout to a webservice to update the content before it is saved using a trigger. Currently I am using "After insert" to get the id of the object and call an async class which would then update the object based on the response from web service. However I would like to change this behavior to before insert in which case the id of the object is returned as null since the object is not saved yet Is there any way I could do this ?
Thanks,
Anil
I need to make a callout to a webservice to update the content before it is saved using a trigger. Currently I am using "After insert" to get the id of the object and call an async class which would then update the object based on the response from web service. However I would like to change this behavior to before insert in which case the id of the object is returned as null since the object is not saved yet Is there any way I could do this ?
Thanks,
Anil
Please try to use future method in trigger for callout.
You won't be able to make the callout synchronously from the trigger, because you would be holding up the transaction (and thus locking records etc) for a potentially long period of time.
Below post will help you
http://www.greytrix.com/blogs/salesforce/2014/10/30/invoke-future-methods-through-apex-trigger-for-web-service-callout/
Please let us know if this will help you
Thanks
Amit Chaudhary