I am trying to copy records from one org to other via web services. I am calling a class which has logic written into a trigger. But @ future method is not taking sObject list as a parameter. Can someone suggest me an alternative?
The Code:
public class webServicesTriggerClass
{
@future public static void webServicesMethod(list<MyFriend__c> mfList)
{
partnerSoapSforceCom.Soap sp = new partnerSoapSforceCom.Soap();
partnerSoapSforceCom.LoginResult lr = sp.login('hitesh.kumar.singh@accenture.com.varun','4Rajyavardhan');
soapSforceComSchemasClassNiralaapp.SessionHeader_element ses = new soapSforceComSchemasClassNiralaapp.SessionHeader_element();
ses.sessionId = lr.sessionId;
soapSforceComSchemasClassNiralaapp.MyFriendsDetailSoapApi vNapp=new soapSforceComSchemasClassNiralaapp.MyFriendsDetailSoapApi();
for(MyFriend__c mf:mfList)
{
string s1= mf.myEmail__c;
string s2=mf.friendName__c;
string s3=mf.friendEmail__c;
string s4=mf.aboutFriend__c;
integer i1=Integer.ValueOf(mf.age__c);
boolean result=vNapp.addFriendDetails(s1,s2,s3,s4,i1);
system.debug('################' +result);
}
}
}
Trigger–>
trigger webServicesTrigger on MyFriend__c (after insert)
{
webServicesTriggerClass.webServicesMethod(trigger.new);
}
Error–
Error: Compile Error: Unsupported parameter type LIST at line 3 column 30
Best Answer
As per documentation
You can't pass sObjects to @future methods:
So I would suggest passing a
Set<ID>
& requerying for the sObject records in your @future method.