Email Notification on Topic Assignment

Email Notification on Topic Assignment

Last Updated on April 5, 2022 by Rakesh Gupta

Big Idea or Enduring Question:

  • How can you notify the topic owner of the Topic Assignment? 


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

  • Create a record-triggered Flow to send custom email notifications for the topic assignment 
  • Create an email template in Flow
  • Use Flow to send a custom email alert
  • and much more

Business Use case

Pamela Kline is working as a System Administrator at Gurukul on Cloud (GoC). She has received a requirement from the management that whenever a Topic KeyAccount gets associated with a record, post, or anywhere then send out an email notification to Topic Owner.

Automation Champion Approach (I-do):

Topics for Objects, allow us to organize the records by using topics the same as Chatter. Topics help to organize records in a better way and make the search easier for you. For example, if you post that you’re working on a presentation for Dreamforce20, you might want to add the hashtag topic #Dreamforce22 or #DF22 in your updates.

Anyone can click on these topics to find out more information about Dreamforce22 and see what people and groups are talking about Dreamforce22. You can also find all records tagged with the topic Dreamforce22. Salesforce allowed you to follow the topic similar to the record, but the glitch is – that you will not get an email notification when a Topic is assigned to a particular post.

To solve this requirement, we will use the After-save Record-Triggered Flow. Check out this article to understand why we are using after-save record-triggered flow for this scenario. One reason for using Flow is EntityId is not accessible in the email template, which means you can not get the record Id where the topic is get associated. 

Let’s take a pause here, and familiarize ourselves with the TopicAssignment and Topic Objects in Salesforce. 

Object Name Details
TopicAssignment It represents the assignment of a topic to a particular feed item or record.
Topic It Represents a topic on a Chatter post or record.

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 understand it.

Let’s begin building this automation process.

Guided Practice (We-do):

There are 4 steps to solve Pamela’s business requirement using Record-Triggered Flow. We must:

  1. Define flow properties for record-triggered flow
  2. Add a Text Template to construct the email body
  3. Add a decision element to check the topic keyAccount is associated
  4. Add send email action  – to notify the topic owner  

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 and configure the flow as follows:
    1. Object: Topic Assignment
    2. Trigger the 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: Add a Text Template to Construct Email Body 

 Now we’ll create an email template using the Text Template. The text template allowed you to specify the multi-line messages.  It also allows you to use HTML code.

  1. Under Toolbox, select Manager, then click New Resource to create a text template. 
  2. Input the following information: 
    1. Resource Type: Text Template
    2. API Name: textT_EmailBody
    3. Select View as Rich Text
    4. Body 
      1. Hi {!$Record.Topic.CreatedBy.FirstName}, 
      2. Topic #KeyAccount just added to this record{!$Record.EntityId} by {!$Record.CreatedBy.FirstName}
      3. Regards,
      4. Automation Champion
  3. Click Done

Step 3: Using Decision Element to Check if the KeyAccount Topic is Associated 

Now we will use the Decision element to check the keyAccount topic is associated with the current TopicAssignment. 

  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: {!$Record.Topic.Name}
      2. Operator: Equals
      3. Value: KeyAccount

Step 4: Add Send Email Action to Notify Topic Owner

Now we will use the Send Email static action to send out an e-mail to the topic owner.

  1. On Flow Designer, below the Yes node, click on the +icon and select the Action element.
  2. Search and select the Send Email from the dropdown menu
  3. Label the new action Notify Topic Owner
  4. Set Input Values
    1. Body: {!textT_EmailBody}
    2. Subject: Topic Assignment Notification – {!$Record.Topic.Name}
    3. Email Addresses (comma-separated): {!$Record.Topic.CreatedBy.Email}
    4. Rich-Text-Formatted Body: {!$GlobalConstant.True}
  5. Click Done.

In the end, Pamela’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: Notify Topic Owner {!$Flow.CurrentDateTime}
  6. Click Save

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

Proof of Concept

Now onwards if a user associates Topic (KeyAccount) to record, post, or anywhere, then the record-triggered flow will fire and notify the topic owner.

  1. Navigate to the Lead tab and associate Topic (KeyAccount) to lead 16744, as shown in the following screenshot:
  2. Warren (Topic Owner) will receive the following email notification.

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 “Email Notification on Topic Assignment

Leave a Reply

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