Getting Started with Process Builder – Part 37 (Auto Add Opportunity Team Member to Opportunity Follower)

Getting Started with Process Builder – Part 37 (Auto Add Opportunity Team Member to Opportunity Follower)

Last Updated on December 30, 2020 by Rakesh Gupta

Big Idea or Enduring Question:

  • How can you automatically add Opportunity Team Members to a follower on an Opportunity?

Objectives:

This blog post will help us to understand the following

  • Launch a Flow from Process Builder
  • Use Flow and Process Builder to automatically create an Opportunity Follower when adding an Opportunity Team Member

Business Use case

Rachel Gillett is working as a System administrator in Universal Container. She has received a requirement from the management that if a new user is added to the Opportunity team, then auto adds the user as an Opportunity follower.

Automation Champion Approach (I-do):

An Opportunity Team is a set of users that usually work together on an opportunity. A typical Opportunity Team might include the account manager, the sales representative, and a pre-sales consultant. In Salesforce a user can follow Chatter groups or Records. As of now, Salesforce does not have any out of the box functionality to auto-follow records when a user is added to a team or etc., apart from the Automatically follow records that you created.

There are a few possible solutions for the above business scenario. We will use Flow and Process Builder to solve the requirement. Check out this article to understand why we are using after-save record-triggered flow for this scenario. 

Let’s take a pause here, familiar yourself with the EntitySubscription object in Salesforce. It represents a subscription for a user following a record or another user. A user can subscribe to a record or to another user.

Field Name Details
ParentId The ID of the record or user which the user is following
SubscriberId The ID of the User who is following the record or user

Before discussing the solution, 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 2 steps to solve Rachel’s business requirement using Flow and Process Builder. We must: 

  1. Lightning Flow Steps:
    1. Define flow properties for auto-launched flow
    2. Add a record variable to store opportunity team member record
    3. Add a get records element to find the follower detail
    4. Add a decision element to check if the record variable (from step 1.3) is null or not
    5. Add a create records element to add the opportunity team member to opportunity follower 
  2. Process Builder Steps:
    1. Define process properties
    2. Define evaluation criteria
    3. Define process criteria
    4. Add action – flows 

Step 1.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 1.2: Lightning Flow – Add a Record Variable to Store Opportunity Team Member Record

  1. Under Toolbox, select Manager, then click New Resource to store opportunity team member record.
  2. Input the following information: 
    1. Resource Type: Variable
    2. API Name: varROpportunityTeamMember
    3. Data Type: Record
    4. Object Opportunity Team Member
    5. Check Available for Input
    6. Check Available for Output
  3. Click Done.

Step 1.3: Lightning Flow – Adding a Get Record Element to Find the Opportunity Follower Details 

The next step is to use the EntitySubscription object to check whether the Opportunity team member is already following the Opportunity or not.

  1. Under Toolbox, select Element
  2. Drag-and-drop Get Records element onto the Flow designer. 
  3. Enter a name in the Label field; the API Name will auto-populate.
  4. Select the Opportunity Team member object from the dropdown list.
  5. Select All Conditions Are Met (AND)
  6. Set Filter Conditions
    1. Row 1:
      1. Field: ParentId
      2. Operator: Equals
      3. Value: {!varROpportunityTeamMember.OpportunityId}
    2. Click Add Condition
    3. Row 1:
      1. Field: SubscriberId
      2. Operator: Equals
      3. Value: {!varROpportunityTeamMember.UserId}
  7. How Many Records to Store:
    1. select Only the firs record
  8. How to Store Record Data:
    1. Choose the option to Automatically store all fields
  9. Click Done.

Step 1.4: Lightning Flow – Using Decision Element to Check the Record Variable (from step 1.3)

Now we will use the Decision element to check the Record Variable from step 1.3 to find if it returns the record follower status for the current opportunity team member or not. 

  1. Under Toolbox, select Element
  2. Drag-and-drop Decision element onto the Flow designer. 
  3. Enter a name in the Label field; the API Name will auto-populate.
  4. Under Outcome Details, enter the Label the API Name will auto-populate.
  5. Condition Requirements to Execute OutcomeAll Conditions Are Met (AND)
    1. Row 1:
      1. Resource: {!Check_follower_details}
      2. Operator: Is Null 
      3. Value: {!$GlobalConstant.True}
  6. Click Done.

Step 1.5: Lightning Flow – Create Records – Add an Opportunity Team member to Opportunity Follower

To add an Opportunity team member to Record Follower drag and drop a Record Create onto the flow designer and map the fields according to the below details. 

  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: Entity Subscription
    5. Set Field Values for the Entity Subscription
    6. Row 1:
      1. Field: ParentId
      2. Value: {!varROpportunityTeamMember.OpportunityId}
    7. Click Add Field
    8. Row 2:
      1. Field: SubscriberId
      2. Value: {!varROpportunityTeamMember.UserId}
  3. Click Done.

In the end, Rachel’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: Add OTP as Opportunity Follower {!$Flow.CurrentDateTime}
  6. Click Save

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

Our next task is to create a Process Builder on the Opportunity Team Member object to launch a Flow. To create a Process Builder on the Opportunity Team Member object follow the below instructions.

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

Step 2.2: Define Evaluation Criteria

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

Step 2.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 
    1. Select No criteria-just execute the actions!.
  4. Click Save.

Step 2.4: Add Action – Flows

  1. Below Immediate Actions, click Add Action.
  2. For Action Type, select Flows
  3. Name the action.
  4. Select the flow we just createdAdd OTP as Opportunity Follower.
  5. Set Flow Variables: 
    1. Row 1:
      1. Flow Variable: varROpportunityTeamMember
      2. Type: Field Reference
      3. Value: Select the Opportunity Team Member record that started your process
  6. Click Save.


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


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

Proof of Concept

  1. Navigate to the Opportunity tab, identify the Opportunity, and click on Opportunity Name.Opportunity with no Team Members
  2. Now I’m going to add user Helina Jolly to the Opportunity Team member, as shown in the following screenshot. Once she has been added as an Opportunity Team member, she will be automatically added as a follower of the Opportunity.Final output

Formative Assessment:

I want to hear from you! 

What did you learn from this post, is it relevant to you, and how will you modify the concepts taught in the post for your own business processes? 

Make a post and tag me on Twitter @automationchamp, using #AutomationChampionPB.

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

4 thoughts on “Getting Started with Process Builder – Part 37 (Auto Add Opportunity Team Member to Opportunity Follower)

  1. Hi Rakesh,

    This post is rather old now. I have create this Process and Flow however it only executes when you click ‘Add’ on Opportunity Team and manually type in the name of the user. When ‘Add Default Team’ is selected, the users are brought forward in the Opportunity Team but the flow does not execute – what would you suggest?

    Kind Regards,
    Liam

  2. Hi Rakesh,

    Is there a way to make the above Flow work when users initially set their default opportunity team member in their ‘My Settings’ area? In other words, it is not working for me when I define my Default Opportunity Team (in Advanced User Details), and then create a new opportunity, the flow does not trigger and add those members as followers to the opportunity. Is there a workaround or alternative solution to accomplish this and have those default team members added? Thanks.

    Regards,
    Nancy Ngo

Leave a Reply

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