Getting Started with Process Builder – Part 26 (Custom Email Notification for Completed Tasks)

Getting Started with Process Builder – Part 26 (Custom Email Notification for Completed Tasks)

Last Updated on January 1, 2021 by Rakesh Gupta

Big Idea or Enduring Question:

How do you send custom email notifications for the completed tasks to the Assignor?


After reading this blog post, the reader will be able to:

  • Create a Process Builder and Flow to send custom email notifications for the completed tasks to the assignor
  • Create an email template in Flow

Business Use case

Warren Mason is working as a System administrator at Universal Containers (UC). He has received a requirement to send out an email notification for completed tasks to the assignor. 

Automation Champion Approach (I-do):

A Lightning Flow or Process Builder will automatically take action when a record meets specified criteria. It has a great capability to send out email notifications to a lot of different objects. This will allow you to notify a person or groups of people via email whenever it meets the evaluation and rule criteria. 

Salesforce doesn’t have out-of-the-box features to notify the assignor when the assignee completes a task. For example, let’s say the Sales manager (Daniela Ruah) assigned a task to a Sales rep (Jessica Smith) to follow-up with one of her key customers to check the status of last quarter’s bills. By default, when Jessica completes the assigned task, Daniela (sales manager) will not receive any email notifications. 

There are a few possible solutions for the above business scenario, but I’ll use Process Builder and Flow to solve the above business requirement. You can also use Apex Triggers or Flow alone to resolve the above business use case. 

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 2 steps to solve Warren’s business requirement using Flow and Process Builder. We must perform the following steps:

  1. Lightning Flow Steps:
    1. Define flow properties for auto-launched flow
    2. Add a record variable to store task record details 
    3. Add a text template to create a dynamic email template  
    4. Add send email action  – to notify assignor  
  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. It will redirect you to Flow Designer

Step 1.2: Lightning Flow – Add a Record Variable to Store Task Record Data

  1. Under Toolbox, select Manager, then click New Resource to store Task record.
  2. Input the following information: 
    1. Resource Type: Variable
    2. API Name: varRTask
    3. Data Type: Record
    4. Object Task
    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 allows 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 {!varRTask.CreatedBy.FirstName},
      2. Task {!varRTask.Subject} ({!varRTask.Id}) is successfully completed by {!varRTask.Owner:User.FirstName}
      3. Regards,
      4. Automation Champion
  3. Click Done.

Step 1.4: Lightning Flow – Add Send Email Action to Notify Assignor 

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

  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: Task Completion Notification – {!varRTask.Subject}
    3. Email Addresses (comma-separated): {!varRTask.CreatedBy.Email}
  6. Click Done.

In the end, Warren’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: Task {!$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 Task object to Launch a Flow, only when a task is completed. To create a Process on the Task 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 Task object from the dropdown list.
  3. Start the process when a record is created or edited.
  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: Task | Status
      2. Operator: Equals
      3. Type: Picklist
      4. Value: Completed
    2. Click Add Row
    3. Row 2
      1. Field: Task | OwnerId
      2. Operator: Starts with
      3. Type: ID
      4. Value: 005
    4. Click Add Row
    5. Row 3
      1. Field: Task | OwnerId
      2. Operator: Does not equal
      3. Type: Field Reference
      4. Value: Task | CreatedById
  5. Select All of the conditions are met (AND)
  6. Click Advanced
  7. Click the Yes checkbox – Do you want to execute the actions only when specified changes are made to the record?
  8. Click Save.

The reason why we would select the Yes checkbox for the question — Do you want to execute the actions only when specified changes are made to the record? — is to allow the Process Builder to execute the actions only if the record meets the criteria now, but the values that the record had immediately before it was saved didn’t meet the criteria. This means that these actions won’t be executed when irrelevant changes are made.

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 createdCustom Email Notification for Completed Tasks.
  5. Set Flow Variables: 
    1. Row 1:
      1. Flow Variable: varRTask
      2. Type: Field Reference
      3. Value: Select the Task record that started your process
  6. Click Save.

In the end, Warren’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 completes the task, the process builder will notify the assignor.

  1. Rakesh Gupta creates a Task and assigns it to user Jessica Brody.
  2. When Jessica completes the assigned task, Rakesh Gupta 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?

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!

16 thoughts on “Getting Started with Process Builder – Part 26 (Custom Email Notification for Completed Tasks)

    1. Assigned To – Represent a Person or Queue to who owns the Task.
      Created By – Person who creates the Task
      Last Modified – The date and timestamp for changes made to an individual record, including the User who made the change.

  1. This is so useful, Rakesh, thank you! (I just implemented based on a user recent request). A comment and a question. Task.OwnerId is the field ‘Assigned To’ of the Task object (I don’t know if this has changed overtime). The question I have is: on the email communication, is there a way to include the record name (e,g,, Campaign Name) the task is attached or related to?

    1. Task.OwnerId is the API name whereas Assigned To is the Field label. If you want to include the record name, you have first to query the record details and then update the Text template.

  2. In the Record lookup, It’s filtering based on Assignor Id and Assignee Id. ( Where Id Equals VarT_AssigneeID & Where id equals VarT_AssignorID). But where did you actually assign values to those variables? Don’t they contain ‘null’? Did you miss that part in this article?

Leave a Reply

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