function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Srikanth Challa 3Srikanth Challa 3 

Task Sharing using S2S

Is it possible to share Case along with the task using Salesforce to Salesforce?

Here is the trigger I am using to automate sharing but only cases are Sharing but for tasks I am supposed to do it manually. Is there any way to automate cases along with tasks and also when we create a new task on the Account even it should flow without any Issue

trigger SendCasesToConnection on Case(after insert, after update) {
{
        PartnerNetworkConnection conn = [select Id, ConnectionStatus, ConnectionName from PartnerNetworkConnection  where ConnectionStatus = 'Accepted' and ConnectionName = 'St. Jude Medical, Inc.'];
        List<PartnerNetworkRecordConnection> recordConnectionToInsert  = new List<PartnerNetworkRecordConnection>  ();
        
        
        for (Case cs : Trigger.new){
       
            PartnerNetworkRecordConnection newrecord = new PartnerNetworkRecordConnection();

            newrecord.ConnectionId = conn.Id;
            newrecord.LocalRecordId = cs.Id;  
            newrecord.SendClosedTasks = false;
            newrecord.SendOpenTasks = true;
            newrecord.SendEmails = false;
            recordConnectionToInsert.add(newrecord);
            
        }
        if (recordConnectionToInsert.size() > 0){
            System.debug('>>> Sharing ' + recordConnectionToInsert.size() + ' records');
            insert recordConnectionToInsert;
        }
      }  
}