Salesforce Certified Application Architect

Friday 27 December 2013

How do we call web services through Triggers?

Using @future annotation in a class. this will make the method of a special type that is a future method which executes asynchronously.
Let take an example which will clearly define how to call webservice through a trigger :
first : Create a class which is calling webservice
public class usingwebservice
{
@future (callout=true)
public static void webcall(string a)
{
// some codew
}
}
Second : Lets create a trigger which will call the class which in-turn will call the web-service
Trigger forwebservice on Sobject__c (after insert)
{
for( SObject__c newrec : trigger.new)
{
usingwebservice.webcall(newrec.id);
}
}

No comments:

Post a Comment

Salesforce Certified Application Architect & Certified Data Architecture and Management Designer Exam

How to pass Salesforce Certified Data Architecture and Management Designer Exam This exam was 1st architect exam for me. Its not that muc...