Salesforce to Salesforce can be used to share the data both within and across Salesforce organizations. Salesforce to Salesforce is a natively supported feature of the Force.com platform and easily enables two dealing partners to share relevant data records in real time. It allows you to share records with your business partners that use Salesforce and get real-time updates on the shared data. For example, you can share Opportunity and Lead data with business partners. Key Pain Points in Salesforce to Salesforce connection is to share the data manually. If you want to automate data sharing process, then you have to use Apex code. Let’s start with a business use case
Business Use case: – Martin Jones is working as System administrator in Universal Container. His company as well as another company (Acme Corp), has enabled Salesforce to Salesforce. He received a requirement from higher management to auto share the new Opportunity with Acme Corp, if opportunity Lead Source doesn’t equal to Web.
Solution of above business requirement
There are multiple solutions possible for the above business scenario. We will use Flow and Process Builder to solve the above business requirement. Before proceeding you have to understand below-mentioned objects in Salesforce
A) PartnerNetworkConnection: -This object represents a Salesforce to Salesforce connection between Salesforce organizations.
B) PartnerNetworkRecordConnection: – This object represents a record shared between Salesforce organizations using Salesforce to Salesforce.
If you haven’t enabled Salesforce-to-Salesforce connection and want to do so, then please have a look at An Introduction to Salesforce to Salesforce article published by Salesforce.com
This article will help you to understand how to auto forward records to a Connection and way to Launch a Flow from Process Builder. Follow the below instructions to create a Flow and Process for the above business requirement
1. Click on Name | Setup | App Setup | Create | Workflows & Approvals | Flows
2. Click on New Flow, it will open the Flow canvas for you, now create one Text variable VarT_OpportunityId to pass the Opportunity Id. We will use this variable in the flow, as shown in the following screenshot
Likewise, create one more Text variable VarT_ConnectionId to store the ID of the connection a record is shared with. To get the Partner Network Connection Id one possible workaround is to use the Developer Console. Click on Name | Developer Console and run the below SOQL query
select ConnectionName,id from PartnerNetworkConnection where ConnectionStatus=’Accepted’
It will look like the following screenshot
You can also find this information from Connection Tab. VarT_ConnectionId will look like the following screenshot
3. The next step is to auto share the Opportunity records with Partner connection. For this, we will use Record Create element. Drag-and-drop Record Update Element on the Flow Canvas and fill the details as shown in the following screenshot
4. Finally, your Flow will look like the following screenshot
5. Click on the Save button and save the Flow with the name Auto Share Opportunity with Connection as shown in the following screenshot
6. Don’t forget to Activate the Flow.
Launch a Flow from the Process Builder
Our next task is to create a Process on Opportunity object to Launch a Flow, only when an Opportunity Lead Source doesn’t equal to Web. To create a Process on the Opportunity object follow the below instructions
1. Click on Name | Setup | App Setup | Create | Workflows & Approvals | Process Builder and click on the New button, Enter Name, API Name and click on the Save button
2. Once you are done click on the Save button, it will redirect you to Process canvas. Click on Object node to add object, Select Opportunity object, in this case, and set the evaluation criteria, Please refer to the following screenshot for more details
3. Once you are done click on the Save button, it will redirect you to Process canvas. The next step is to define Process criteria. For this click on Add Criteria node, enter Criteria Name, Set filter conditions (Similar to Rule Criteria in WFR), as shown in the following screenshot
4. Once you are done click on the Save button, it will redirect you to Process canvas. Now we have to add an Immediate action into the Process to Launch a Flow. For this use Flows action. Use Field Picker to select the field Description and Text Entry field to enter a comment or sentence. Please refer the following screenshot for more information
5. Once you are done click on the Save button, it will redirect you to Process canvas. Finally, the Process will look like the following screenshot
Don’t forget to active the Process by clicking on the Activate button
It’s time to test this Process
Now onwards if a business user creates a new Opportunity record with Lead Source other than the Web, then Process Builder will automatically share it with Partner Network Connection Acme Corp
1. Now create a new Opportunity with Name “Burlington Textiles Weaving Plant Generator – Second Phase” and Lead Source blank. Then check the External Sharing related list available on the Opportunity Detail page, as shown in the following screenshot
Process Builder automatically shared the new Opportunity with partner network connection Acme Corp.
Note: – I will suggest you to implement this first on your developer org test it and then move it to Production.