Getting Started with Process Builder – Part 10 (Auto forward Records to a Connection)

Getting Started with Process Builder – Part 10 (Auto forward Records to a Connection)

Last Updated on December 21, 2020 by Rakesh Gupta

Big Idea or Enduring Question:

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.

One key pain point in the Salesforce-to-Salesforce connection is sharing data manually. If you want to automate the data sharing process, then you have to use the Apex code. In this case, we’re able to accomplish this with a couple of declarative tools and no coding required. 

(Please note that Salesforce to Salesforce Connections is only available in Classic at this time. We’re not sure if Salesforce plans to support this in lightning. We can switch to classic to set up the connection for this tutorial.)

Objectives:

After reading this blog post, the reader will be able to:

  • Understand the Salesforce-to-Salesforce connection capabilities
  • Understand which options are available for sharing records with partners
  • Share data seamlessly with automation
  • Get exposure to Lightning Flow

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’s required to share all opportunities that didn’t originate from the “web” lead source. Considering the volume of opportunities, Martin needs to automate this.

Automation Champion Approach (I-do):

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 the below-mentioned objects in 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. In this tutorial, we’re going to set up a Salesforce to Salesforce connection with a fictitious company, Acme. To set this up, please follow the instructions listed here.

This article will help you to understand how to auto-forward records to a Connection and how to launch a Flow from Process Builder. If you’re unfamiliar with the flow and its capabilities, I’d recommend checking out our tutorials on Flow listed here.  

Before discussing it, let me show you a diagram of a Process Flow at a high level. Please spend a few minutes to go through the following Flow diagram and understand it.

Let’s begin building this automation process.

Guided Practice (We-do):

There are 4 steps to solve Martin’s business requirement using Flow and Process Builder. We must: 

  1. Find partner network connection Id
  2. Creating a custom label to store opportunity id
  3. Lightning Flow Steps:
    1. Define flow properties for auto-launched flow
    2. Add a text variable to store an opportunity record data
    3. Add a create records element  – share the record with the auditor 
  4. Process Builder Steps:
    1. Define process properties
    2. Define evaluation criteria
    3. Define process criteria
    4. Add action – flows 

Step 1: Find Partner Network Connection Id for Acme Corp  

The first step is to find out the Connection Id for partner network Acme Corp. One possible workaround is to use the Developer Console. 

  1. Click Setup | Developer Console 
  2. In the Query Editor, run the following SOQL query 
    1. select ConnectionName, Id from PartnerNetworkConnection where ConnectionStatus=’Accepted’
  3. Make sure to copy Connection Id. 

SOQL Query - To get Partner Network Connection Id  

Step 2: Creating a Custom Label 

Create one custom label to store the ID of the connection a record is shared with. 

  1. Click Setup.
  2. In the User Interface, type Custom Labels.
  3. Click on the New Custom Label button.
  4. Enter Short Description the Name will auto-populate. 
  5. Now enter the Acme Corp Connection Id in the Value.
  6. Click Save.

Step 3.1: Lightning Flow – Define Flow Properties 

  1. Click Setup.
  2. In the Quick Find box, type Flows.
  3. Select Flows then click on the New Flow.
  4. Select the Autolaunched Flow (No Trigger) option and click on Next and configure the flow as follows: 
    1. How do you want to start building: Freeform
  5. Click Done.

Step 3.2: Lightning Flow – Add a Text Variable to Store Opportunity Id

  1. Under Toolbox, select Manager, then click New Resource to store Opportunity Id.
  2. Input the following information: 
    1. Resource Type: Variable
    2. API Name: varTOpportunityId
    3. Data Type: Text
    4. Default Value: {!GlobalConstant.EmptyString}
    5. Check Available for Input
    6. Check Available for Output
  3. Click Done.

    

Step 3.3: Lightning Flow – Create Records – Forward Opportunity Record to Acme Corp 

The next step is to auto-share the Opportunity records with Partner connection. For this, we will use the Create Records element. We’ll essentially duplicate our current record into the established connection org by pointing our record to a new record in the connected Salesforce instance.

  1. Under Toolbox, select Elements. Drag and drop Create Records onto the canvas. 
  2. Input the following information:
    1. Enter Label the API Name will auto-populate.
    2. How Many Records to Create: One
    3. How to Set the Record Fields: Use separate resources, and literal values
    4. Object: Connection History
    5. Set Field Values for the Connection History
    6. Row 1:
      1. Field: ConnectionId
      2. Value: {!$Label.Acme_Corp_Connection_Id}
    7. Click Add Row
    8. Row 2:
      1. Field: LocalRecordId
      2. Value: {!varTOpportunityId}
  3. Click Done.

In the end, Martin’s Flow will look like the following screenshot:

Once everything looks good, perform the steps below: 

  1. Click Save.
  2. Enter Flow Label the API Name will auto-populate.
  3. Click Show Advanced.
  4. API Version for Running the Flow: 50
  5. Interview Label: Auto Forward Record to Connection {!$Flow.CurrentDateTime}
  6. Click Save

Almost there! Once everything looks good, click the Activate button.  

Our next task is to create a Process on the Opportunity object to launch a Flow, only when an Opportunity Lead Source is not equal to the Web

Step 4.1: Define Process Properties

  1. Click Setup.
  2. In the Quick Find box, type Process Builder.
  3. Select Process Builder, then click New.
  4. Name the Process and click the Tab button. The API Name will populate. 
  5. As a best practice, always input a description
  6. The process starts when A record changes.
  7. Click Save.

Define Process Properties

Step 4.2: Define Evaluation Criteria

  1. Click on the Add Object node to begin selecting the evaluation criteria.
  2. Select the Opportunity object from the dropdown list.
  3. Start the process only when a record is created.
  4. Click Save.

Evaluation Criteria

Step 4.3: Define Process Criteria

  1. Click the Add Criteria node to begin defining the process criteria.
  2. Name the criteria.
  3. The criteria should execute actions when the conditions are met.
  4. Set Conditions
    1. Row 1
      1. Field: Opportunity| LeadSource
      2. Operator: Does not equal
      3. Type: Picklist
      4. Value: Web
  5. Select All of the conditions are met (AND)
  6. Click Save.

Step 4.4: Add Action – Flow

  1. Below Immediate Actions, click Add Action.
  2. For Action Type, select Flows
  3. Name the action.
  4. Select the flow we just createdAuto Forward Record to Connection.
  5. Set Flow Variables: 
    1. Row 1:
      1. Flow Variable: varTOpportunityId
      2. Type: Field Reference
      3. Value: Opportunity | Id
  6. Click Save.

In the end, Martin’s Process will look like the following screenshot:

Almost there! Once everything looks good, click the Activate button. 

Proof of Concept

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 the 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:Auto Share Opportunity with Connection
  2. Process Builder automatically shared the new Opportunity with partner network connection Acme Corp

Formative Assessment:

Identify a custom object in your org that should be shared based on the settings in a related object and create an autolaunched flow that will share the records without actual manual sharing

Post a picture of the sharing on Twitter @automationchamp, #AutomatedSharingwithFlow

Have feedback, suggestions for posts, or need more information about Salesforce online training offered by me? Say hello, and leave a message!

17 thoughts on “Getting Started with Process Builder – Part 10 (Auto forward Records to a Connection)

  1. 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

      1. 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.

  2. 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

          1. Thanks for the reply :), I have done this but still the second one “is not connected to anything” is still stopping me to activate

  3. 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?

  4. 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.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.