Pages

Cross Organization Data Sharing

If you are looking for a mechanism to share data between two organisations for the sake of real time data sharing and don't want to use any third party application or no more code customisation then Salesforce Cross Organisation Data Sharing is the best way to do it.

This is still the pilot project of Salesforce so you will not see any links in shown here in your Production or any other Sandboxes these are only available in Developer Orgs.

Salesforce data from different org can be shared using the cross org data sharing. This is completely different than copying data from one org to another org using Salesforce to Salesforce connections. Consider a scenario where you have two different orgs one maintains the Inventory information and let’s say second org is required to report on the available items from Inventory. In this case both the systems works on the same data. It wont be a best practice to copy the data from inventory system to reporting system just for the sake of reporting. There are other problems also, might be an issue of delay in the copy which might result in the incorrect result of reporting.

Salesforce Cross Org Data Sharing works in the Hub-Spoke mechanism where all the information flows from Hub to all the Spoke.


Hub-Spoke Topology

Hub - is the org which contains the data we want to share
Spoke - is the org which will use the shared data from Hub. Data resides only in Hub and is shared (displayed) in all the Spoke. No data is copied to Spoke. You can have one Hub working as Spoke for other data type and vice-versa.

Let's get started with a simple data sharing of Accounts between two orgs. For doing so we will have to

1. Configure Hub to share the data
2. Configure Spoke so as to access the shared data from Hub
3. Write the Query to fetch the data

Following is my Hub org where I have Account data which I want to share with other Orgs.

1. Configure Hub to share the data 
Go to Setup --> Data Management --> Cross-Organization Data --> Hub Configuration
Click on New button. Now enter the Hub Name and Unique Name as shown below and check the checkbox against Constrained.


Selecting Constrained checkbox makes sure that whenever you un share the shared object it will show you an error message.

Once you click on Save you will see Hub Details with two more sections Objects and Fields and Spoke Connections.

Go to Objects and Fields Section and click on Edit button, you will see list of the Objects you can share. (Currently you can share Account and Custom Objects Only.) Select Account and click on Save.


Now click on Account under the Objects and Fields and choose the fields you want to share. Please keep in mind Salesforce at this moment does not allow you to share the user related fields like ownerid, createdBy fields. Once you select all the fields you want to share click Save.


Now goto the Spoke Connections Section and click on New Connection button. Here you will be asked to enter the connection name. After entering the name when you click on Save, Salesforce will show a long text which you can use as a code from Spoke to connect to this Hub.


2. Configure Spoke so as to access the shared data from Hub 
Now logon to your Spoke Org and go to.

Setup --> Data Management --> Cross-Organization Data --> Spoke Configuration and click on New XOrgSpoke button.

This will ask you for the Object Label and name, enter the values and click Save. After Save you will see Accept Invitation button, click on this button to create a connection between Hub and Spoke. Here you will have to provide the long text from Hub to connect. On entering the long text system will try to connect to Hub as shown below in the Status.


Once the connection is established you can sync the data by clicking on Sync with Hub button on the Spoke Configuration page. Once the sync is complete you will see all the objects shared from Hub are shown under the Proxy Objects section as below.



Click on Account and you will see all the fields which we shared on the Hub for Account object.

3. Write the Query to fetch the data
Now we will try to test the Connection by writing the SOQL to fetch the records and will test it. Open the Developer Console and write the following query to fetch the records.


Now test the query result. You can find more details from Salesforce Help here .




No comments:

Post a Comment