We would like to set up a S2S connection to publish Cases to another org. But we only want cases with the custom field, Client Type = 'TypeA' to be sent. How can we prevent a user forwarding cases with a different Client Type? Thanks.

1 Answer 1


I can not give you a direct solution, but there is an indirect way if you are willing to automate s2s sending.

2 steps are required:

  1. remove the button from the page layout (Case list view) - this will prevent users from manually sending Cases to another org.

  2. create a trigger to automate sending. Example below.

trigger CaseShareWithConsultingOrg on Case (after insert, after update) {
List<PartnerNetworkConnection> connection = [select Id, ConnectionStatus, ConnectionName from PartnerNetworkConnection  
                                                where ConnectionStatus = 'Accepted'];
    if(connection.size() > 0){
        List<PartnerNetworkRecordConnection> recordToShareToInsert = new  List<PartnerNetworkRecordConnection>();       
            for(Case myCase: Trigger.new){
                PartnerNetworkRecordConnection recordToShare = new PartnerNetworkRecordConnection();
                recordToShare.ConnectionId = connection[0].Id;
                recordToShare.LocalRecordId = myCase.id;  
                recordToShare.SendClosedTasks = false;
                recordToShare.SendOpenTasks = false;
                recordToShare.SendEmails = false; 
                if(myCase.Clint_Type__c = 'TypeA') {
                insert recordToShareToInsert;
            catch (Exception  e){   
                System.debug('CUSTOM ERROR === ' + e);

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .