July 5, 2021

How to forward records using Apex in Salesforce to Salesforce

Sample Code:

PartnerNetworkConnection network = [ SELECT Id FROM PartnerNetworkConnection WHERE ConnectionStatus = 'Accepted' LIMIT 1 ];
List < PartnerNetworkRecordConnection > listConnections = new List < PartnerNetworkRecordConnection >();
PartnerNetworkRecordConnection connection = new PartnerNetworkRecordConnection();
connection.ConnectionId = network.Id;
connection.LocalRecordId = '0015Y00002dfRIF';//Id of the record to be shared to the other Salesforce Org
listConnections.add( connection );
insert listConnections;

No comments:

Post a Comment