+ Start a Discussion
SforcehariSforcehari 

Trigger to Salesforce to Salesforce is Not working In Production.

Hai to Salesforce,

 

   I have configured Salesforce to salesforce beween to Orgs,

 

  I have written a trigger to send Inserted contacts automatically insert in to Partner network orgnization.

 

 I have published account and Contact objects and subscribed  there also.I have mapped the fiedls also.

 

 But while inserting Contact My trigger throws an exception like Invalide Partnet network status.Not able to insert.Error At line 65 .

Trigger autoforwardContact on Contact(after Insert){
 String  UserName = UserInfo.getName();
 String orgName = UserInfo.getOrganizationName(); 
 List<PartnerNetworkConnection> connMap = new List<PartnerNetworkConnection>(
  [select Id, ConnectionStatus, ConnectionName from PartnerNetworkConnection where ConnectionStatus = 'Accepted'] );
System.debug('Size of connection map: '+connMap.size());
 List<PartnerNetworkRecordConnection> prncList = new List<PartnerNetworkRecordConnection>(); 
for(Integer i =0; i< Trigger.size; i++){ 
Contact con = Trigger.new[i];
String conId = con.Id;
System.debug('Value of ContactId: '+conId);

for(PartnerNetworkConnection network : connMap) 

String cid = network.Id;
String status = network.ConnectionStatus;
String connName = network.ConnectionName; 
String ContactName = con.LastName;
String Accountid = con.Accountid;
System.debug('Connectin Details.......Cid:::'+cid+'Status:::'+Status+'ConnName:::'+connName+'ContactName:::'+COntactName);
System.debug('Account ID************'+Accountid);
if(ContactName!= NULL){
 System.debug('INSIDE IF');  PartnerNetworkRecordConnection newrecord = new PartnerNetworkRecordConnection(); 
  newrecord.ConnectionId = cid;
  newrecord.LocalRecordId = ConId;    newrecord.ParentRecordId= Accountid;
  newrecord.SendClosedTasks = true;
  newrecord.SendOpenTasks = true;   newrecord.SendEmails = true;
  System.debug('Inserting New Record'+newrecord);
 insert newrecord;}
}}}

 

This is my trigger code,it is working fine in My dev login,is there any thing i am missing?

 

Regards,

Haribabu Amudalapalli