You need to sign in to do that
Don't have an account?
William Hines
Tasks not sharing with partner connection in S2S
I have been developing my S2S connection within two sandbox environments. I can get Contacts and Accounts to forward over with no problem, however, the child activity objects are not included. I understand that the subscribing org needs to have the parent objects (Contacts) selected to auto-accept. This is currently the case. All available fields are mapped properly for both orgs, and again Contacts and Accounts are forwarded with no problem. I cannot get the tasks to carry over with a manual action or programmatic forwarding. The code that relates specifically to sharing contacts is as follows:
PartnerNetworkRecordConnection newConnection;
newConnection =
new PartnerNetworkRecordConnection(
ConnectionId = networkId,
LocalRecordId = newContact.Id,
RelatedRecords = 'Opportunity,Task,Attachment,Case',
SendClosedTasks = true,
SendOpenTasks = true,
SendEmails = true,
ParentRecordId = newContact.AccountId);
contactConnections.add(newConnection);
PartnerNetworkRecordConnection newConnection;
newConnection =
new PartnerNetworkRecordConnection(
ConnectionId = networkId,
LocalRecordId = newContact.Id,
RelatedRecords = 'Opportunity,Task,Attachment,Case',
SendClosedTasks = true,
SendOpenTasks = true,
SendEmails = true,
ParentRecordId = newContact.AccountId);
contactConnections.add(newConnection);
global class ShareContactsWithPartner implements Database.Batchable<sObject>{
global String email;
global Id networkId;
global List<Id> shareContactsSelection = new List<Id>();
global ShareContactsWithPartner(List<Id> listShareContactsSelection)
{
shareContactsSelection = listShareContactsSelection;
}
global Database.QueryLocator start(Database.BatchableContext BC)
{
return Database.getQueryLocator([SELECT Id, AccountId FROM Contact WHERE Id IN: shareContactsSelection]);
}
global void execute(Database.BatchableContext BC, List<Contact> scope)
{
List<PartnerNetworkRecordConnection> contactConnections = new List<PartnerNetworkRecordConnection>();
for (Contact newContact : scope) {
PartnerNetworkRecordConnection newConnection;
newConnection =
new PartnerNetworkRecordConnection(
ConnectionId = networkId,
LocalRecordId = newContact.Id,
SendClosedTasks = true,
SendOpenTasks = true,
SendEmails = true,
ParentRecordId = newContact.AccountId);
contactConnections.add(newConnection);
}
if (contactConnections.size() > 0 ) {
System.debug('Inserting contactConnections!');
database.insert(contactConnections);
}
}
global void finish(Database.BatchableContext BC)
{
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setToAddresses(new String[] {email});
mail.setReplyTo('batch@riskxinvestments.com');
mail.setSenderDisplayName('Batch Processing');
mail.setSubject('Batch Process Completed');
mail.setPlainTextBody('Batch Process has completed');
Messaging.sendEmail(new Messaging.SingleEmailMessage[]{ mail });
}
}