Getting Started with Salesforce Flow – Part 80 (Auto update Chatter Email Settings)

Getting Started with Salesforce Flow – Part 80 (Auto update Chatter Email Settings)

Last Updated on November 22, 2021 by Rakesh Gupta

Big Idea or Enduring Question:

Chatter is a great way to boost collaboration in your organization. Users can post a status, links, files, and comments on other’s posts. We can also add users to chatter groups. Chatter can email you every time someone follows you, posts to your profile or groups, etc. To learn more about chatter and find out how to get started, please check out Trailhead

Chatter becomes even more powerful through automation. We can make changes to records and settings in an automatic fashion that reduces human error. In this tutorial, we’ll see the power of the Salesforce Flow when combined with Chatter.

Objectives:

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

  • Get a better understanding of Chatter
  • Use Salesforce Flow to update Chatter email settings
  • Realize what’s possible with Chatter and Salesforce Flow

Business Use case

Tamara McCleary is working as a System administrator at Universal Containers (UC). She has received a requirement to auto-update new user’s Chatter email settings when they’re onboarded. The requirements are below.

  1. Update the personal digest frequency: – Weekly
  2. Update the default email frequency for groups I join: Email on each post

Automation Champion Approach (I-do):

There are multiple solutions possible for the above business scenario. We will use Salesforce Flow to solve the above business requirement.

To solve this requirement, we will use the Before-save Record-Triggered Flow. Check out this article to understand why we are using after-save record-triggered flow for this scenario.

Before proceeding you have to understand the User object and some of its fields in Salesforce.

A) DefaultGroupNotificationFrequency: – This field represents the default frequency for sending the user’s Chatter group email notifications when the user joins groups. The options are as follows:

  • Email on every post
  • Daily digests
  • Weekly digests
  • Limited

B) DigestFrequency: – This field represents the frequency at which the system sends the user’s Chatter personal email digest. The options for DigestFrequency are as follows:

  • Daily
  • Weekly
  • Never

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

  1. Define flow properties for record-triggered flow
  2. Create a formula to determine whether the quote record is new or old
  3. Add a decision element to check the IsActive field
  4. Add an assignment element  – assign default values to the following fields:
    1. DefaultGroupNotificationFrequency
    2. DigestFrequency

Step 1: Lightning Flow – Define Flow Properties For Before-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. Object: User
    3. Trigger the Flow When: A record is created or updated
    4. Set Entry Criteria
      1. Condition Requirements: None
    5. Optimize the Flow For: Fast Field Updates
  5. Click Done.

Tips: Never try to write entry criteria in a Record-Triggered Flow. Why? Check out this article.

Step 2: Salesforce Flow – Formula to Determine Whether the User Record is New or Old

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

Step 3: Salesforce Flow – Using Decision Element to Check the IsActive Field

Now we will use the Decision element to check the IsActive to ensure that it is equal to True and record is New. 

  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 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. Resource: {!$Record.IsActive}
      2. Operator: Equals
      3. Value: {!$GlobalConstant.True}
  6. Click Done.

Step 4: Salesforce Flow – Using Assignment Element to Update Email Digest Settings

The next step is to update an User record. We will use the Assignment element, as we are using before-save flow. 

  1. Under Toolbox, select Element
  2. Drag-and-drop Assignment element onto the Flow designer. 
  3. Enter a name in the Label field; the API Name will auto-populate.
  4. Set Variable Value
    1. Row 1:
      1. Field: {!$Record.DefaultGroupNotificationFrequency}
      2. Operator: Equals
      3. Value: P
    2. Click Add Row
    3. Row 2:
      1. Field: {!$Record.DigestFrequency}
      2. Operator: Equals
      3. Value: W
  5. Click Done.


In the end, Tamara’s Flow will look like the following screenshot (I turned on Auto-Layout) for this flow:

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: 53
  5. Interview Label: Record-Trigger: User Before Save {!$Flow.CurrentDateTime}
  6. Click Save.

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

Proof of Concept

Now onwards, if the system administrator creates a new user by going to Setup, typing Users, and clicking New. Fill in the required fields and save the record. If you’re an administrator, log in as the user and check their settings. Otherwise, have the user log in and check their settings.  


Now it’s your turn to try something with Salesforce Flow and Chatter or Slack. There are lots of options. Try to post to a group to let everyone know a new user has been added or post directly to the person’s manager. Come up with your own Flow with Chatter and let us know what you’ve done.

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!

 

7 thoughts on “Getting Started with Salesforce Flow – Part 80 (Auto update Chatter Email Settings)

  1. Is there any way to access the DefaultGroupNotificationFrequency and DigestFrequency fields via the UI, say when editing the User record? Seems like these should be standard fields that an admin should be able to set on a user’s behalf without needing a workflow.
    By the way, thank you so much for all of these examples! I am working my way through all of them.

Leave a Reply

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