Salesforce 使用Sales Force to Sales Force Connector与Opportunity共享主要联系人

Salesforce 使用Sales Force to Sales Force Connector与Opportunity共享主要联系人,salesforce,Salesforce,潜在客户-转换为客户、联系人和商机 我开发了一个触发器,它与我们的另一个组织共享一个机会和相关帐户,我缺少的是与此共享联系人。还需要一些帮助来分享联系人 Trigger autoforwardOpportunity on Opportunity(after insert) { String UserName = UserInfo.getName(); String orgName = UserInfo.getOrganizationName(); List<PartnerNet

潜在客户-转换为客户、联系人和商机

我开发了一个触发器,它与我们的另一个组织共享一个机会和相关帐户,我缺少的是与此共享联系人。还需要一些帮助来分享联系人

     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;
        }
    }
    }
}
在Opportunity上触发autoforwardOpportunity(插入后){
字符串UserName=UserInfo.getName();
字符串orgName=UserInfo.getOrganizationName();
List connMap=新列表(
[从PartnerNetworkConnection中选择Id、ConnectionStatus、ConnectionName,其中ConnectionStatus='Accepted']
);
System.debug('连接映射的大小:'+connMap.Size());
List prncList=新列表();
for(整数i=0;i
newrecord.RelatedRecords='Contact,Opportunity'//等