Salesforce to Salesforce Integration
While working on my last project one client requirement was to share records from one org to another org.
This blog introduces Salesforce to Salesforce integration, shows how one can enable it, how to manage connections between different environments and how to share data using the connections.
Before using S2S, we need to perform a few pre requisites,
1.Enable it first in our salesforce org.
2.As well as on the org with which we are going to share data.
Enabling Salesforce to Salesforce
navigate to Setup -> App setup -> Customize -> Salesforce to Salesforce -> Settings. Edit, select Enable, and then select Save.
Setting up a Connection
Let’s assume that company 1, as well as company 2, have enabled Salesforce to Salesforce. Even though both orgs have S2S enabled, we have to establish a formal relationship between the orgs before sharing can take place. This is done by setting up a connection.
As a best practice, in company 1, create an account representing the company 2 that will receive the connection, and also create a contact with email address under that account. This contact will typically be used when sending the S2S connection invitation.
Click On the Connections tab, click New to create a new connection with another org.
Once the invitation is accepted, the connection to Company 2 is established. In connection details section we can see the connection status as active. No objects (standard or custom) are shared yet. Only data we choose to share will be shared. For sharing the data we need to publish the object.
A one-way share between two environments is achieved by having the source environment publish, and the target environment subscribe.
Once the connection is established, the next step is to publish. let’s publish objects from Company 1.
- Do this by clicking on Publish in the Connection tab, and selecting the object that we wish to publish. We can publish standard objects and all custom objects. For now we’ve selected Account.
- Now we need to choose the fields that we wish to publish. Select Edit on an object to choose the fields that we wish to publish to the other environment.
Subscribing to Published Objects
The receiving environment (Company 2 in our case) doesn’t automatically have access to the data published from the Company 1 environment. Rather, the org must first subscribe to the objects.
Login to Company 2 and subscribe to these two objects and map the fields. This is done by navigating to the Connections tab, selecting the Appirio connection, and hitting “Subscribe”. You’ll now be presented with a list of the published objects to which you can subscribe:
If this option is selected, then records from the publishing org will be automatically accepted – the process will be entirely automatic. If you don’t select the checkbox, then an administrator will first have to review incoming records before they are accepted. The checkbox is not always displayed. In particular, child objects are automatically accepted if parent objects are accepted, and the option is not available for junction objects either.
Field Mappings and considerations
Map fields by clicking on Edit next to each object.
Here’s a little more about this field mapping and how to resolve these.
- You can map a Text Field to any other field of equal or greater size.
- Lookup or reference fields can be mapped to text fields(of size 80 or greater).
- Auto number fields can also be mapped to toext fields (of size 30 or greater).
- Lookup IDs are not available for publishing. You can enable S2S for those fields by creating a formula field and then publishing the formula field. In advanced section of formula field.
Using the Shared Connection
Let’s have a look on how the s2s connection can be used.
One way share among two org is achieved by having source org publish and target org suscribe. Here source org acts as a master and would overwrite shared records in target org whenever there is a change to the record in the source environment.
Any changes made to the shared record in target org are lost.
Two-way share between orgs is achieved by having both orgs publish and subscribe to each others objects. Now shared records between the two org synchronize whenever there is a change on either side.
In both cases, the Salesforce to Salesforce mapping determines which fields would flow from one org to the other.
Sharing of Records
Go to List view for the object and Select the records and click on “Forward to connection”. Select the connection and related objects if there are any, and save.
When records are forwarded, records will be automatically created in the target environment if auto-accept for the object is enabled. If it’s not enabled, the records sent will need to be explicitly accepted in the target environment as shown in screenshots below. In particular, in the target environment select the object (Account in this example) tab, click on the Go button in “Accounts from connections”:
Then click on “Accept” to accept the record in the target org.
When two organizations wants to share data they can use S2S which provides a mechanism to transfer records from source to destination instances but also allows us to edit the values of the records which were transferred. The changes made to the records in the source instance will be replicated in the records in the destination instance.