Getting Started with Salesforce Flow – Part 54 (Auto-follow a Chatter Question After Reply)

Getting Started with Salesforce Flow – Part 54 (Auto-follow a Chatter Question After Reply)

Last Updated on May 13, 2021 by Rakesh Gupta

Big Idea or Enduring Question:

How do you ensure a user is notified about additional replies to a Chatter Question she answered?

With Chatter Questions, users can ask questions in their Chatter feed, in groups, and in records. Select Question from the Chatter publisher’s action menu, or click the Question tab. After a question is asked, moderators and the person who asked the question can select the best answer. The best answer is prominently displayed in the feed, allowing other users to quickly and easily find the information they need.

Your users can organize their information with the question title and details about their question. They can ask the question to their followers, to a group, or to a specific person, as they can with other Chatter feed items. 

In the past, I have written a few articles on automating Questions and automation. Why not check them out while you are at it?! 

  1. Getting Started with Process Builder – Part 29 (Auto Remove Followers from Questions with best replies)

Objectives:

After reading this article, you will be able to:

  • Use Flow to identify if a user is already following a question
  • If the user is not following the question, add the user as a follower
  • Automatically trigger a Flow upon a question being answered

Business Use Case 

Universal Containers is using Chatter Questions for their Internal support. When users answer questions, they don’t remember to go back and check for subsequent questions or feedback. Leadership has reminded everyone to follow the questions they answer, but people don’t usually remember. Therefore, Leadership has asked Steven Greene, a Lead System Administrator to come up with a solution so users are always added as followers to questions they answer.

Automation Champion Approach (I-do):

There are a few possible solutions for the above business scenario, but I’ll use After-save Record-Triggered Flow to solve the business 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 QuestionSubscription Object in Salesforce. It represents a subscription for a user following a Question.

Field Name Details
QuestionId The Id of the Question which the user is following.
SubscriberId The Id of the User who is following the Question

Whereas Reply represents a reply that a user has submitted to a question in an answers community. 

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 Steven’s business requirement using Salesforce Flow. We must:

  1. Enable Replies to a Question they follow
  2. Salesforce flow
    1. Define flow properties for record-triggered flow
    2. Add a get records element to find the question subscriber detail
    3. Add a decision element to check if the record variable (from step 2.2) is null or not
    4. Add a create records element to add a user to question follower 

Step 1: Enable Replies to a Question They Follow

If you have experience with Answers in the Trailblazer Community, you have used this functionality.  And you also know, once you reply to a Question you will auto-follow it. The Benefit of following a Question is you will get an email notification about any replies. However, this feature must be enabled. To see if it is, follow the steps below:

  1. In Salesforce Classic, click Setup.
  2. In the Quick Find, type Email Notification Settings.
  3. Click on the Edit button.
  4. Select Replies to a question they follow checkbox. 
  5. Click Save.

Step 2.1: Salesforce Flow – Define Flow Properties 

As we have a requirement of creating a record in (CollaborationGroupRecord), this is why we have to use After Save flow. 

  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 and click on Next and configure the flow as follows: 
    1. How do you want to start building: Freeform
    2. Trigger the Flow When: A record is created
    3. Run Flow: After the record is saved
    4. Object: Reply
  5. Condition Requirements: None
  6. Set Conditions: None
  7. Click Done.

Step 2.2: Salesforce Flow – Adding a Get Record Element to Find the Question Subscriber Detail

The next step is to use the QuestionSubscription object to check whether the current user (person who just replied to a question) is already following the Quetsion 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 Record QuestionSubscription object from the dropdown list.
  5. Select All Conditions Are Met (AND)
  6. Set Filter Conditions
    1. Row 1:
      1. Field: QuestionId
      2. Operator: Equals
      3. Value: {!$Record.QuestionId}
    2. Add Condition
    3. Row 2:
      1. Field: SubscriberId
      2. Operator: Equals
      3. Value: {!$User.Id}
  7. How Many Records to Store:
    1. select Only the first record
  8. How to Store Record Data:
    1. Choose the option to Automatically store all fields
  9. Click Done.

 

Step 2.3: Salesforce Flow – Using Decision Element to Check the Record Variable (from step 2.2)

Now we will use the Decision element to check the Record Variable from step 2.2 to find if it returns the question follower status for the current user 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: {!Question_Follower}
      2. Operator: Is Null 
      3. Value: {!$GlobalConstant.Flase}
  6. Click Done.

Step 2.4: Salesforce Flow – Create Records – Add a User to Question Follower 

To add a user to Question 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: Question Subscription
    5. Set Field Values for the Entity Subscription
    6. Row 1:
      1. Field: QuestionId
      2. Operator: Equals
      3. Value: {!$Record.QuestionId}
    7. Add Field
    8. Row 2:
      1. Field: SubscriberId
      2. Operator: Equals
      3. Value: {!$User.Id}
  3. Click Done.

In the end, Steven’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. Type: Record-Triggered Flow
  5. API Version for Running the Flow: 51
  6. Interview Label: Auto follow a question after reply {!$Flow.CurrentDateTime}
  7. Click Save

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

Proof of Concept

Now onwards if a user replies to a Question, Salesforce Flow will automatically add them as a question follower.

  1. Navigate to the Q&A tab and find the Question to which you want to reply/answer. Question
  2. Right now the follower count is 0.
  3. Now reply to a question, as soon as you are done with the reply refresh the page and check the follower count.Reply to Question
  4. The follower count is now at 1.

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? 

Let me know by Tweeting me at @automationchamp, or find me on LinkedIn.

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

8 thoughts on “Getting Started with Salesforce Flow – Part 54 (Auto-follow a Chatter Question After Reply)

Leave a Reply

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