S2S

trigger trgOnBankS2SExample on Bank__c (after Insert) {



List<Contact>lstCon = new List<Contact>();
        lstCon =[Select Id from Contact where id='0039000000mi2am'];
      List<PartnerNetworkConnection>    lstPnC = new List<PartnerNetworkConnection>();
        lstPnC = [select Id, ConnectionStatus, ConnectionName from PartnerNetworkConnection where ContactId =:lstCon[0].id and ConnectionStatus='Accepted'];
       
        List<PartnerNetworkRecordConnection> recordConnectionToInsert  = new List<PartnerNetworkRecordConnection>  ();
        for (Bank__C BObj : Trigger.new){  
            PartnerNetworkRecordConnection newrecord = new PartnerNetworkRecordConnection();
            newrecord.ConnectionId = lstPnC[0].Id;
            newrecord.LocalRecordId = BObj .id;
            recordConnectionToInsert.add(newrecord);
         
        }
        if (recordConnectionToInsert.size() > 0){
            System.debug('>>> Sharing ' + recordConnectionToInsert.size() + ' records');
            insert recordConnectionToInsert;
        }



}

Comments

Popular posts from this blog

Salesforce Spring 16 Release Exam (Maintenance Exam Q&A) for Developer 201 Admin

Show Hyper Link On Add Error in Salesforce Trigger

Show the Success Message before Redirecting the Detail page on Visualforce Page