Getting Started with Process Builder – Part 39

Getting Started with Process Builder – Part 39

Big Idea or Enduring Question:

  • What is the best way to automatically add topic(s) to a record?

Objectives:

What follows is a blog post that will help us understand

  • Launch a flow from the Process Builder
  • Using Flow and Process Builder, you can automatically add topics to a record 

Business Use case

System administrator Pamela Kline is employed by Universal Containers (UC). Currently, she has a requirement from management that if a new opportunity over 1M is created, then the existing account #KeyAccount should be automatically added to the opportunity record. 

Automation Champion Approach (I-do):

Topics for Objects allow us to organize the records by using topics similar to Chatter. By using topics, you can organize records better and make your search easier. You might want to use the hashtag #Dreamforce20 in your updates if you're working on a presentation for Dreamforce20.

You can click on these topics to find out more about Dreamforce20 and see what groups and people are talking about Dreamforce20. The topic Dreamforce20 is also found in all records.

For the above business scenario, there are a few possible solutions. Process Builder will be used to address the problem. Learn why we are using after-save record-triggered flow in this scenario by reading this article. 

Here, let's familiarize ourselves with TopicAssignment and TopicObjects in Salesforce. 

Object NameDetails
TopicAssignmentIt represents the assignment of a topic to a particular feed item or record.
TopicIt Represents a topic on a Chatter post or record.

Let me show you a high-level Process Flow before discussing the solution. Spend a few minutes looking at the flow diagram below 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. Defining flow properties for auto-launched flows
  2. Store opportunity record data in a record variable 
  3. Adding a get records element to find the id of the topic (KeyAccount)
  4. To add a topic to the opportunity record, add a record element to create records

2.Steps in the Process Builder:

  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 Opportunity Record

  1. Under Toolbox, select Manager, then click New Resource to store opportunity record.
  2. Input the following information: 


  1. Resource Type: Variable
  2. API Name: varROpportunity
  3. Data Type: Record
  4. Object Opportunity
  5. Check Available for Input
  6. Check Available for Output

3.Click Done.


Step 1.3: Lightning Flow – Adding a Get Record Element to Find the Topic (KeyAccount) Id 

To find the topic #KeyAccount Id, use the Get Records element.

  1. Click Element in the Toolbox. 
  2. Drag and drop the Get Records element onto the Flow designer. 
  3. The API Name will be auto-populated when you enter a name in the Label field.
  4. Choose the Topic object from the dropdown list.
  5. Select All Conditions Are Met (AND). 
  6. Set Filter Conditions

                  1.Row 1:

  1. Field: Name
  2. Operator: Equals
  3. Value: KeyAccount

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 1.4 Adding the #KeyAccount topic to the opportunity is the final step. Add the Record Create flow to the flow designer and map the fields according to the below details. In this case, I am assuming that a Topic with the name KeyAccount already exists in your organization. 

  1. Select Elements from the Toolbox. Select Create Records and drop it on the canvas. 
  2. Please enter 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: Topic Assignment 
  5. Set Field Values for the Topic Assignment 
  6. Row 1:

            1.Field: EntityId

            2.Value: {!varROpportunity.d}

7.Click Add Field

8.Row 2:

       1.Field: TopicId

        2.Value: {!Topic_keyAccount_Id.Id}

3.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: Assign topic to a record {!$Flow.CurrentDateTime}
  6. Click Save. 


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

Our next task is to create a Process Builder on the Opportunity object to launch a Flow. To create a Process Builder on the Opportunity object follow the below instructions.

Step 2.1: Define Process Properties

  1. Click Setup.
  2. Type Process Builder in Quick Find.
  3. Click New after selecting Process Builder.
  4. Click the Tab button to name the process. A list of API names will appear. 
  5. It is best to always include a description. 
  6. When A record changes, the process begins.
  7. Click Save.


Step 2.2: Define Evaluation Criteria

  1. Select the evaluation criteria by clicking on the Add Object node.
  2. Choose the Opportunity object from the dropdown menu.
  3. Create a new record before starting the process.
  4. Click Save.


Step 2.3: Define Process Criteria

  1. Add criteria by clicking the Add Criteria node.
  2. Identify the criteria.
  3. When the criteria are met, actions should be taken.
  4. Specify conditions

              1.Row 1

  1. Field: Opportunity | Amount
  2. Operator:  Greater than
  3. Type: Currency
  4. Value: 1000000


 5.Select All of the conditions are met (AND). 

  6.Click Save.


Step 2.4: Add Action – Flows

  1. Click Add Action below Immediate Actions.
  2. Select Flows as the Action Type. 
  3. Identify the action.
  4. Choose the flow we just created - Assign topic to a record.
  5. Set the flow variables as follows: 

                         1.Row 1:

                                   1.varROpportunity: Flow Variable

                                    2.Field Reference Type

                                  3.Choose the Opportunity record that started your process

  6.Save the file.


Pamela's Process will end up looking like this:


We're almost there! Click the Activate button as soon as everything looks good. 

Conceptual proof

Whenever a sales rep creates or updates an opportunity with more than $1.2M, Process Builder automatically adds #KeyTopic to it. 

1.k on the Opportunities tab and create a new Opportunity record with an amount of 1.2 M, as shown in the screenshot below:


2.Check out the Topic section of the page


Formative Assessment:

I want to hear from you! 

What did you learn from this post, is it relevant to your business, and how will you use the concepts taught in the post to improve your business processes? 

Tweet me @automationchamp and use #AutomationChampionPB.