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
}
}
{
@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);
}
}
{
for( SObject__c newrec : trigger.new)
{
usingwebservice.webcall(newrec.id);
}
}
No comments:
Post a Comment