Custom Email Notification for Completed Tasks

Custom Email Notification for Completed Tasks

Last Updated on April 3, 2022 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 record-triggered Flow to send custom email notifications for the completed tasks to the assignor
  • Create an email template in Flow
  • Use Send Email flow action

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 Salesforce Flow 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 meets the conditions specified. 

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. 

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.

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 warren’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 if the task owner and the assignor are not the same people
  4. Add a core action send email to send out an email

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: Task
    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 Create Dynamic Email Template

 Now we’ll create an email template using the Text Template. The 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: textT_EmailBody
    3. Select View as Rich Text
    4. Body 
      1. Hi {!$Record.CreatedBy.FirstName},
      2. Task {!$Record.Subject} ({!$Record.Id}) is successfully completed by {!$Record.Owner:User.FirstName}
      3. Regards,
      4. Automation Champion
  3. Click Done.

Step 3: Using Decision Element to Check if Status is Completed and, Task Owner and Assignor is Not Same Person

Now we will use the Decision element to check the following:

  • Task status is completed
  • Task owner must be a Salesforce User
  • Task owner and assignor is different people
  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.Status}
      2. Operator: Is Changed
      3. Value: {!$GlobalConstant.True}
    2. Add Condition
    3. Row 2:
      1. Resource: {!$Record.Status}
      2. Operator: Equals
      3. Value: Completed
    4. Add Condition
    5. Row 3:
      1. Resource: {!$Record.OwnerId}
      2. Operator: Start With
      3. Value: 005
    6. Add Condition
    7. Row 4:
      1. Resource: {!$Record.OwnerId}
      2. Operator: Does Not Equal
      3. Value: {!$Record.CreatedById}
  5. When to Execute Outcome: If the condition requirements are met.
  6. Click Done.

Step 4: 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. On Flow Designer, below the Completed 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 Assignor
  4. Set Input Values
    1. Body: {!textT_EmailBody}
    2. Subject: Task Completion Notification – {!$Record.Subject}
    3. Email Addresses (comma-separated): {!$Record.CreatedBy.Email}
    4. Rich-Text-Formatted Body: {!$GlobalConstant.True}
  5. 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: 54
  5. Interview LabelRecord-Triggered: Task After Save {!$Flow.CurrentDateTime}
  6. Click Save

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

Proof of Concept

Now onwards if a user completes the task, the salesforce flow 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? 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!

33 thoughts on “Custom Email Notification for Completed Tasks

  1. How I am able to add additional recipient just like email alert in Flow ? I am trying to use “Recipient Email Addresses (comma-separated)” option but it prompt me error that I am in an invalid email format. Currently under this section already have a Get Record resource created to grab the email from user in Account Team and I would like to add an additional email but not a user in Salesforce.

    1. You have to try something like this:

      1. Create a Text variable Collection
      2. Add Account Team member’s email to the Text Variable
      3. Add Text variable to Email Addresses (Collection) when using Send Email static action
      4. Add Additional email to Email Addresses (comma-separated)

  2. First of all Thank you for the detailed approach to explain the functionality.
    I created a flow but Emails are not getting Delivered.
    deliverability is set to all emails., Using API version 56

  3. Hello Rakesh. Thank you so much for this! One issue I’m coming across is when I enter {!$Record.CreatedBy.Email} in the Send Email action, it gives me an error saying “These issues don’t prevent activation, but can cause problems when you run the flow.
    Notify_Task_Assignor (Action) – These email addresses are invalid: {!$Record.CreatedBy.Email} . Use this format:” Any idea of how to resolve this? Thank you again!

      1. Thank you for the quick reply! No luck unfortunately. The flow is activated but when I had my co-worker mark the task as completed, no email notification came through. The flow won’t even let me save changes with {!$Record.CreatedBy.Email} inputted unless I add a space or comma at the end of it. And when I do that, it gives me the error I mentioned initially. Are there any workarounds that you’re aware of? Thank you again!

              1. It’s working now after changing the API version to 49 and updating the values. Thank you for your help and your excellent blog!

    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.

  4. 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.

  5. 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.