Getting Started with Process Builder – Part 41 (Email Notification on Topic Assignment)

Getting Started with Process Builder – Part 41 (Email Notification on Topic Assignment)

Last Updated on December 1, 2020 by Rakesh Gupta

Big Idea or Enduring Question:

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

Objectives:

This blog post will help us to understand the following

  • Launch a Flow from Process Builder
  • Use Flow to send a custom email alert
  • Create an email template in Flow
  • Use Flow and Process Builder to automatically notify the topic owner on Topic Assignment 

Business Use case

Pamela Kline is working as a System administrator at Universal Containers (UC). 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 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 #Dreamforce20 or #DF20 in your updates.

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

There are a few possible solutions for the above business scenarioWe will use Flow and Process Builder to solve the requirement. 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, familiar yourself 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 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 Pamela’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 topic assignment record details 
    3. Add a text template to create a dynamic email template  
    4. Add send email action  – to notify the topic owner  
  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 Topic Assignment Record Data

  1. Under Toolbox, select Manager, then click New Resource to store Topic Assignment record.
  2. Input the following information: 
    1. Resource Type: Variable
    2. API Name: varRTopicAssignment
    3. Data Type: Record
    4. Object Topic Assignment
    5. Check Available for Input
    6. Check Available for Output
  3. Click Done.

Step 1.3: Lightning Flow – Add a Text Template to Create Dynamic Email Template

 Now we’ll create an email template using the Text Template. 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: ttEmailBody
    3. Select View as Plain Text
    4. Body 
      1. Hi {!varTopicAssignment.Topic.CreatedBy.FirstName},
      2. Topic #KeyAccount just added to this record https://myautomationchampion-dev-ed.my.salesforce.com/{!varTopicAssignment.EntityId} by {!varTopicAssignment.CreatedBy.FirstName}
      3. Regards,
      4. Automation Champion
  3. Click Done.

Step 1.4: Lightning Flow – 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 (KeyAccount) Owner. 

  1. Under Toolbox, select Element.
  2. Drag-and-drop Action element onto the Flow designer. 
  3. Select SendEmail out-of-the-box action. 
  4. Enter a name in the Label field; the API Name will auto-populate.
  5. Set Input Values
    1. Body: {!ttEmailBody}
    2. Subject: Topic Assignment Notification – {!varTopicAssignment.Topic.Name}
    3. Email Addresses (comma-separated): {!varTopicAssignment.Topic.CreatedBy.Email}
  6. 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.

Our next task is to create a Process on the Topic Assignment object to Launch a Flow, only when a topic (keyAccount) is associated. To create a Process on the Topic Assignment object, follow the instructions below:

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 Topic Assignment 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 when the conditions are met.
  4. Set Conditions
    1. Row 1
      1. Field: TopicAssignment | Topic | Name
      2. Operator: Equals
      3. Type: String
      4. Value: KeyAccount
  5. Select All of the conditions are met (AND)
  6. 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 createdNotify Topic Owner.
  5. Set Flow Variables: 
    1. Row 1:
      1. Flow Variable: varRTopicAssignment
      2. Type: Field Reference
      3. Value: Select the TopicAssignment record that started your process
  6. Click Save.

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

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 process builder 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 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 41 (Email Notification on Topic Assignment)

Leave a Reply

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