function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
anvesh@force.comanvesh@force.com 

Can we call web services through trigger?

Can we call web services through trigger?

Best Answer chosen by Admin (Salesforce Developers) 
imutsavimutsav
An Apex trigger can execute a callout when the callout is invoked within a method defined as asynchronous: that is, defined with the @future keyword. The @future annotation signifies that the Apex method executes asynchronously.

check this for @future
http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content/apex_classes_annotation.htm#future

let me know if you have any question

Thanks
Utsav

[Do mark this answer as solution if it works for you and give a kudos.]

All Answers

imutsavimutsav
An Apex trigger can execute a callout when the callout is invoked within a method defined as asynchronous: that is, defined with the @future keyword. The @future annotation signifies that the Apex method executes asynchronously.

check this for @future
http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content/apex_classes_annotation.htm#future

let me know if you have any question

Thanks
Utsav

[Do mark this answer as solution if it works for you and give a kudos.]
This was selected as the best answer
anvesh@force.comanvesh@force.com
i didnt understand what wxactly will u breifely xplains this
imutsavimutsav
you can only call asynchronous web service from a Trigger. that means when you call a Web service from a trigger then then controller will not wait for the function to return any value etc. it would call the web service and without waiting for the reply or status update it would go to the next line. You won't know if the web service was called successfully or if there was an error etc. Controller will just call the web service and would go to the next line.

Do give a kudos by clicking on the star if it answered your question.


Thanks
Utsav
Joe BriaticoJoe Briatico
Can you perform DML in the future method?  Normally you can't do it in a trigger.
yvk431yvk431
You can perform the dml in future, its just that you wont know the result or wait for it.

--yvk