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 Salesforce 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 the data sharing process, then you have to use the Apex code. Let’s start with a business use case
Business Use case
Martin Jones is working as a System administrator at Universal Containers (UC). His company as well as another company (Acme Corp), has established Salesforce-to-Salesforce. He has received a requirement from higher management to auto-share the new opportunities with Acme Corp if opportunity Lead Source doesn’t equal to Web.
Solution for the 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. To create a Flow, navigate to Setup (Gear Icon) | Setup | PLATFORM TOOLS | Process Automation | Flow.
2. Now click on the New Flow button; it will open the Lightning Flow Designer for you. Now create one Text variable VarT_OpportunityId to store 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 Setup (Gear icon) | 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 the Create Records element. Drag-and-drop Create Records Element on the Lightning Flow Designer 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. The next step is to create a process, that will fire when a new user gets created. To do this, Navigate to Setup (Gear Icon) | Setup | Process Automation | Process Builder
2. To create a new process from scratch, click on the New Button available on Process Management page. A popup will appear where you have to enter the Name, API Name and Description as shown in the screenshot below:
3. 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 the 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

Process Criteria
Process Criteria
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 implement this first on your developer org test it and then move it to Production.
17 thoughts on “Getting Started with Process Builder – Part 10 (Auto forward Records to a Connection)”
Avesh Lakha
How can we attach the opportunity to that existing account for which the opportunity was created in source org?
Paul
got this to work on Case thanks to your steps great write up! now the business wants to expand this to include any attachments to be shared on the case. any words of wisdom on how to share related attachments?
kindest – Paul
Rakesh Gupta
Do you mean as soon as attachment added into the case record?
Paul
Hi,
Currently, when a case has the owner set to a specific Queue, i have a Process builder that kicks off a flow and shares the case over via Salesforce to Salesforce connection ( this part is where your tips and tricks REALLY helped out). now the business would like for any attachments to also share over. i’m thinking i could have my flow to a fast lookup to see if the are any attachments with the Case ID but i’m a bit foggy on the specifics.
Rakesh Gupta
Try the same approach to share the attachment and let me know how it goes.
Prasad Shiraskar
Hi Rakesh,
Is there a way to share the public post on a case from one SF instance to another SF instance (S2S) via Flow? I’m able to share the case but the Public post isn’t getting shared. Need your help
Rakesh Gupta
Never tried but looks like it is possible.
prathyusha
Could not able to activate the flow could you please explain this, we are getting warnings on this
Rakesh Gupta
Could you please share the warning message screenshot?
prathyusha
Here i am trying to share contact records instead of opportunities.
Flow Must have a start item.
it is not connected to anything.
Rakesh Gupta
Your flow must have an start item. Over your mouse on Flow element and then click on the green arrow to set a start item
prathyusha
Thanks for the reply :), I have done this but still the second one “is not connected to anything” is still stopping me to activate
Rakesh Gupta
Ignore general warning and your flow will work.
kyle
This was very easy to follow, good job. A question I have is how to scale this up to a real world scenario. For example, you wouldn’t want to forward an opportunity or another related record like a contact, without the account too. In your example, if you just transfer the opportunity, it becomes orphaned. So, what is necessary to scale this up to either associated with the an account that has already been forwarded too or to create this missing account?
Rakesh Gupta
Thanks for the kind feedback, Kyle! Glad you got it working 🙂
In that case, you have to pass Account details. Check out PartnerNetworkRecordConnection object for more details. Either you can pass opportunities while passing account record or vice versa.
Darrell DeVeaux
We do this now but use a Record Lookup to get the Connection ID. This requires that the Account name be on the record you are forwarding, assuming you might have multiple Salesforce to Salesforce connections.
Rakesh Gupta
Yes you are right Darrell, if some org has multiple S2S connection then they have to use Record Lookup to get Connection ID. Thank you 🙂