Auto Add Opportunity Team Member to Opportunity Follower

Auto Add Opportunity Team Member to Opportunity Follower

Last Updated on June 7, 2022 by Rakesh Gupta

Big Idea or Enduring Question:

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

Objectives:

After reading this blog, you’ll be able to: 

  • Work with get records element to find the record
  • Use decision element to check record values
  • Use create records element to automatically add followers to an opportunity
  • and much more

Business Use case

Rachel Gillett is working as a System Administrator at Gurukul on Cloud (GoC). 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 I create.

There are a few possible solutions for the above business scenario. We will use Flow 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, and familiarize 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 going through the following Flow diagram and understanding it.

Let’s begin building this automation process.

Guided Practice (We-do):

There are 5 steps to solve Rachel’s business requirement using Record-triggered Flow. We must:

  1. Define flow properties for record-triggered flow
  2. Formula to determine whether the record is created or updated
  3. Add a get records element to find the follower detail for the current team member 
  4. Add a decision element to check whether the team member is following the opportunity record or not
  5. Add a create records element to add the opportunity team member to the opportunity follower 

Step 1: 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 Record-Triggered Flow option, click on Create 
    1. Object: Opportunity Team Member
    2. Trigger Opportunity Flow When: A record is created or updated
    3. Set Entry Criteria
      1. Condition Requirements: None
    4. Optimize the Flow For Action and Related Records
  5. Click Done.

Step 2: Formula to Determine Whether the record is Created or Updated

  1. Under Toolbox, select Manager, then click New Resource to determine whether the record is created or updated. 
  2. Input the following information:
    1. ResourceType:Formula
    2. API Name: forB_IsNew
    3. Data Type: Boolean
    4. Formula: IsNew()
  3. Click Done.

Step 3: Adding a Get Record Element to Find the Opportunity Follower Details  for the Current Team Member 

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

  1. On Flow Designer, click on the +icon and select the Get Records element.
  2. Enter a name in the Label field; the API Name will auto-populate.
  3. Select the Entity Subscription object from the dropdown list.
  4. Select All Conditions Are Met (AND)
  5. Set Filter Conditions
    1. Row 1:
      1. Field: ParentId
      2. Operator: Equals
      3. Value: {!$Record.OpportunityId}
    2. Click Add Condition
    3. Row 2:
      1. Field: SubscriberId
      2. Operator: Equals
      3. Value: {!$Record.UserId}
  6. How Many Records to Store:
    1. Select Only the first record
  7. How to Store Record Data:
    1. Choose the option to Automatically store all fields
  8. Click Done.

Step 4: Using Decision Element to Check Whether the Team Member is Following the Opportunity Record or Not

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

  1. On Flow Designer, click on the +icon and select the Decision element.
  2. Enter a name in the Label field; the API Name will auto-populate.
  3. Under Outcome Details, enter the Label the API Name will auto-populate.
  4. Condition Requirements to Execute Outcome: All Conditions Are Met (AND)
    1. Row 1:
      1. Resource: {!forB_IsNew}
      2. Operator: Equals
      3. Value: {!$GlobalConstant.True}
    2. Click Add Condition
    3. Row 2:
      1. Field: {!Get_Follower}
      2. Operator: Is Null
      3. Value: {!$GlobalConstant.True}
  5. When to Execute Outcome: If the condition requirements are met.
  6. Click Done.

Step 5: Create Records – Add an Opportunity Team member to Opportunity Follower

To add an Opportunity team member to Record Follower we will use Create Records element. 

  1. On Flow Designer, click on the +icon and select the Create Records element.
  2. Enter a name in the Label field; the API Name will auto-populate.
  3. Input the following information:
    1. How Many Records to Create: One
    2. How to Set the Record Fields: Use separate resources, and literal values
    3. ObjectEntity Subscription 
    4. Set Field Values for the Entity Subscription
    5. Row 1:
      1. Field: ParentId
      2. Value: {!$Record.OpportunityId}
    6. Click Add Field
    7. Row 2:
      1. Field: SubscriberId
      2. Value: {!$Record.UserId}
  4. 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: 55
  5. Interview Label: Auto Add Opportunity Team Member to Opportunity Follower {!$Flow.CurrentDateTime}
  6. Click Save.

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.
  2. Now I’m going to add user Nathan Gilmore 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.

Formative Assessment:

I want to hear from you!

What is one thing you learned from this post? How do you envision applying this new knowledge in the real world? Feel free to share in the comments below.

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