2014-02-24 47 views
1

主角 - 被轉換成客戶,聯繫人和機會分享使用銷售人員的銷售力的接插件的機會沿主聯繫人

我開發了共享的機遇和相關的說法與我們的其他組織的觸發,而我失去的一塊是與這一起分享聯繫。還需要一些幫助來分享聯繫人。

 Trigger autoforwardOpportunity on Opportunity(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++) { 
    Opportunity Opp = Trigger.new[i]; 
    String acId = Opp.Id; 
    System.debug('Value of OpportunityId: '+acId); 
    for(PartnerNetworkConnection network : connMap) { 
     String cid = network.Id; 
     String status = network.ConnectionStatus; 
     String connName = network.ConnectionName; 
     String AssignedBusinessUnit = Opp.Assigned_Business_Unit__c; 
     System.debug('Connectin Details.......Cid:::'+cid+'Status:::'+Status+'ConnName:::'+connName+','+AssignedBusinessUnit); 
     if(AssignedBusinessUnit!=Null && (AssignedBusinessUnit.equalsIgnoreCase('IT') || AssignedBusinessUnit.equalsIgnoreCase('Proservia'))) {  
      // Send account to IT instance 
      PartnerNetworkRecordConnection newAccount = new PartnerNetworkRecordConnection(); 
      newAccount.ConnectionId = cid; 
      newAccount.LocalRecordId = Opp.AccountId; 
      newAccount.SendClosedTasks = true; 
      newAccount.SendOpenTasks = true; 
      newAccount.SendEmails = true; 
      newAccount.RelatedRecords = 'Contact'; 
      System.debug('Inserting New Record'+newAccount); 
      insert newAccount; 

      // Send opportunity to IT instance 
      PartnerNetworkRecordConnection newrecord = new PartnerNetworkRecordConnection(); 
      newrecord.ConnectionId = cid; 
      newrecord.LocalRecordId = acId; 
      newrecord.SendClosedTasks = true; 
      newrecord.SendOpenTasks = true; 
      newrecord.SendEmails = true; 
      //newrecord.ParentRecordId = Opp.AccountId; 
      System.debug('Inserting New Record'+newrecord); 
      insert newrecord; 
     } 
    } 
    } 
} 

回答

0

newrecord.RelatedRecords ='Contact,Opportunity'; //等