Our partner also has Salesforce implementation as such we plan to deploy the out of the box Salesforce to Salesforce for obtaining leads from them.

This is an amazing feature but looks like our partner company actually "owns" the record..by that I mean any changes they make ,once the record is shared, automatically overwrites the record in our downstream org.

Is there a way to prevent just the update but allow the insert ?

I tried the following validation rule but that does not seem to work. No errors is obtained while saving the validation rule but the update restriction does not seem to be happening.

LastModifiedBy.Id = 'XXXX', 

So does this mean that any record that is "published" by a upstream Salesforce implementation via S2S will always overwrite the changes made by the downstream Salesforce instance ?

  • and what is XXXX? ... the only value I can think of that would plausibly work is the ID of the Connection User and if that worked for you, you'd want to use LastModifiedBy.name='Connection User' for clarity
    – cropredy
    Commented Mar 25, 2016 at 22:26

2 Answers 2


The documentation for PartnerNetworkRecordConnection shows how to programmatically stop sharing a record

List<PartnerNetworkRecordConnection> recordConns = new List<PartnerNetworkRecordConnection>(
    [select Id, Status, ConnectionId, LocalRecordId from PartnerNetworkRecordConnection
        where LocalRecordId in :accounts]

   for(PartnerNetworkRecordConnection recordConn : recordConns) {
        if(recordConn.Status.equalsignorecase('Sent')){ //account is connected - outbound
            delete nets;
  • upvote for the much better answer than mine Commented Mar 25, 2016 at 22:26

Programmatically stop sharing on the downstream org after insertion of the record. I have a screenshot of the UI with the External Sharing related list.

enter image description here

This means the downstream org will no longer accept updates to this record from the upstream org.

You must log in to answer this question.

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