SALESFORCE 2 SALESFORCE
Activation
By Default S2S is inactive.Setting for the Salesforce 2 Salesforce can be found in:
Built à customize à Salesforce 2 Salesforce à Settings
Salesforce 2 Salesforce Setting page
Salesforce 2 Salesforce Settings:
Shows the status of the Salesforce 2 Salesforce Status (Enable and Disable).
Deliverability:
Option to control the Email Id Email template which will be used while sending the email communication.Create a Connection
To share record between the Org they need to be connected. Once we activate the Salesforce 2 Salesforce we get a new tab: “Connections”. Connections tabs shows all the connection currently available in the org along with option to create one.New Connection:
Connection is created using a contact. The email in contact is used to send the invitation for the connection. Choose the desired contact in contact field. On saving the connection email invite will be sent.Sample Email invitation received
Through the link in email, admin can accept or decline the connection request.
Once the connection is accepted it connection status turns to “Active”.
Publish and Subscribe Object
Salesforce to Salesforce uses Publish and Subscribe Model to control the
Publish- subscribe Model
In publish–subscribe design pattern where senders of data/messages, called publishers, do not send the data/messages directly to specific receivers, called subscribers. Instead, published data/messages are characterized into classes, without knowledge of what, if any, subscribers there may be. Similarly, subscribers express interest in one or more classes, and only receive data/messages that are of interest, without knowledge of publisher.Publish Objects
Once the connection is created publisher (Source Org) can select the object that it want to publish.Connection detail page has Related List section with name “Published Object”. “Publish/ Unpublish” button is used to manage the published object.
Click on the button “Publish/Unpublish” button following screen will appear, where you can select the object you want to publish and un-select the object you want to un-publish.
Publish Fields
Now the object are published. By default only the Mandatory fields of standard object are published. To publish more fields following step is needs to be done.Edit action on child records under “Published Object” Related List is used to control the fields to publish.
![]() |
| Edit Action on Published object related List |
On Edit Action following screen appears. Select the field to publish and un select the fields to un-publish the fields.
![]() |
| Publish the fields of an object |
Subscribe Objects
Once the Destination Org accept the connection invitation. This org is now potential subscriber. Subscriber can subscribe to the object that are published by the Publisher (Source Org).Connection detail page has Related List section with name “Subscribed Object”. “Subscribe/ Unsubscribe” button is used to manage the published object.
Click on the button “Subscribe/ Unsubscribe” button following screen will appear. Map the published object with the object present in your org. To unsubscribe map the published object to “NONE”.
Important points to note:
- Specific standard object can be mapped with only Specific standard object only. I.e.., Contact to Contact, Account to Account.
- Custom object can be mapped with other custom objects.
- If “Auto Accept” is checked the records shared for this object are auto accepted or else the users need to manually accept the records. The awaiting records for accepting are seen in home page of object under the list “object from Connection”.
Subscribe Fields
After subscribing to the object, the fields published in this object need to be mapped. The Edit Action on the Subscribed Object is used to the map the fields.![]() |
| Subscribe object related list in connection detail page |
Following page appear when edit action is clicked.
Important points to note
- You can’t map a standard number field to a custom number field.
- You can map lookup fields to text fields that have a length of 80 or more characters.
- You can map auto number fields to text fields that have a length of 30 or more characters.
- You can map formula fields to fields of the same data type.
Share a Record
Now when the two org are connected and object are subscribed, records can be externally shared and records are in sync with the published org.Each records is to be shared individually. All these shared records are always in sync in subscribed org.
Once the object is published for S2S external sharing, a new related list (children) is included for object. The name of related list is “External Sharing”. If the External Sharing is not visible, add to layout by editing the page layout.
The button “Forward this contact” is used to share the current records externally using S2S.
The status of the record sharing can be seen in external sharing related list.
Sharing can be stopped using the action “Stop Sharing”.
The below image of a shared records in subscriber org. The notification on the records detail page specifies that this records is shared by the connection.
![]() |
| An Sample Record shared by S2S |
Deactivation
The connection can be deactivated from the connection detail page. The option available to deactivate is “deactivate”.On deactivate, the records shared earlier in this connection are still available for access at destination org but update are will no longer be sent.
Salesforce to Salesforce in a glance
The following flow diagram will give a big picture of how the salesforce to salesforce works![]() |
| S2S flow in a glance |
Template
In a scenario where, a set of objects and fields are needed to be published for different connections, template can be used. Templates are used to define a set of object and its fields to publish and use it for various connection.Template List
Template Edit page
Select the template while creating the connection and all the object and field configuration are inherited to the new connection created.
Share via Apex
Besides manually externally sharing the record using the “Forward to Connection” button, record can also be shared using an apex code.Programmatically Query all S2S Connection in org
All the connection are present in the object “PartnerNetworkConnection”. Query the object to get all the connection present in the Org.List< PartnerNetworkConnection> connections = [Select id, ConnectionName, ContactId, ConnectionStatus, ConnectionType From PartnerNetworkConnection];
Programmatically sharing a record
To externally share a record, create a record of type “PartnerNetworkRecordConnection” with record id to share and connection Id (returned by the above query).PartnerNetworkRecordConnection newConnection =
new PartnerNetworkRecordConnection(
ConnectionId = networkId,
LocalRecordId = newContact.Id,
SendClosedTasks = false,
SendOpenTasks = false,
SendEmails = false,
ParentRecordId = newContact.AccountId);
insert newConnection;
Tip; Write the above code as per the logic in trigger to serve the various purpose as required.
Bidirectional Record Sync
If the requirement is to have bi directional sync of record, i.e.., when changed in Org 1 reflect it in Org 2 and vise versa.No proper document to achieve this, after multiple trails the trick found to achieve this bi directional record sync is as follow.
- Create a connection.
- Publish the object and fields from Org 1 and subscribe the object and fields in Org 2.
- Now, publish the same object and fields from Org 2 and subscribe the object in Org 1.



















No comments:
Post a Comment