Custom Email Notification for Completed Tasks

Advertisements

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?

Objectives:

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} (https://myautomationchampion-dev-ed.lightning.force.com/{!$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!
Preferred Timing(required)

37 thoughts on “Custom Email Notification for Completed Tasks

  1. Hi Rakesh, thank you for sharing this solution. Can you advice on how to set up email notification when a step is NOT completed? Ideally, a notification should be sent to a manager of a Sales Representative with information on the overdue steps. How would you go about configuring this? Thank you!

    1. Rakesh Gupta – Mumbai – 9x Salesforce MVP | Senior Solution Architect | 8x Author | 5x Dreamforce Speaker | Salesforce Coach | Co-host of AutomationHour.com and AppXchangeHour.Com

      Sure, to set up email notifications for uncompleted tasks, you have two options: either use a time-dependent action in Flow or use a Scheduled-Triggered Flow.

      If you mean uncompleted steps in a completed task, then add a decision in the same flow to check the step criteria and send out an alert to the manager.

  2. Thank you, Rakesh. This is so helpful. Have you try replacing the email body text template for a lightning template? I have a similar use case but is on the “Deliverable” object (NPSP custom object) but I haven’t been able to make it work because I keep missing the “Recipient ID”. Maybe the functionality it is not available if you trigger in custom objects?

    1. I’m glad you found the information useful! Regarding your question about replacing the email body text template with a Lightning template, it’s definitely a viable approach.

      If you could provide more details about your current use case, setup and the specific issues you’re facing with the “Recipient ID”, I might be able to offer more specific insights. Understanding the exact nature of the problem will help in diagnosing the issue more effectively.

  3. 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)

    1. Yes, if queue has an email address.

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

    1. Check out this article on how to Troubleshoot Delivery Problems for Salesforce Emails.

  5. 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: user@example.com.” Any idea of how to resolve this? Thank you again!

    1. Rakesh Gupta – Mumbai – 9x Salesforce MVP | Senior Solution Architect | 8x Author | 5x Dreamforce Speaker | Salesforce Coach | Co-host of AutomationHour.com and AppXchangeHour.Com

      I tried in my developer org, and it didn’t give any error to me. Active the Flow and test it and let me know how it goes.

      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. Rakesh Gupta – Mumbai – 9x Salesforce MVP | Senior Solution Architect | 8x Author | 5x Dreamforce Speaker | Salesforce Coach | Co-host of AutomationHour.com and AppXchangeHour.Com

          Please share send email and Flow screenshots with me.

            1. Rakesh Gupta – Mumbai – 9x Salesforce MVP | Senior Solution Architect | 8x Author | 5x Dreamforce Speaker | Salesforce Coach | Co-host of AutomationHour.com and AppXchangeHour.Com

              Check your email. I am happy to help.

            2. Rakesh Gupta – Mumbai – 9x Salesforce MVP | Senior Solution Architect | 8x Author | 5x Dreamforce Speaker | Salesforce Coach | Co-host of AutomationHour.com and AppXchangeHour.Com

              Don’t copy and paste values from blog instead manually enter the value by clicking Record > Created By > Email.

            3. Rakesh Gupta – Mumbai – 9x Salesforce MVP | Senior Solution Architect | 8x Author | 5x Dreamforce Speaker | Salesforce Coach | Co-host of AutomationHour.com and AppXchangeHour.Com

              😊

    1. Is it possible to send a screenshot to me?

    1. Rakesh Gupta – Mumbai – 9x Salesforce MVP | Senior Solution Architect | 8x Author | 5x Dreamforce Speaker | Salesforce Coach | Co-host of AutomationHour.com and AppXchangeHour.Com

      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.

  6. Gustavo Seluja – Santa Fe, New Mexico – Information technology professional with more that twenty years of experience. Education and background in biomedical, biotechnology and healthcare industries, and a focus on solutions, systems, operations and services. Experienced product and project manager, team and technical lead as well as system owner and administrator. Salesforce Certified Administrator. Fluent in Spanish.

    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. Rakesh Gupta – Mumbai – 9x Salesforce MVP | Senior Solution Architect | 8x Author | 5x Dreamforce Speaker | Salesforce Coach | Co-host of AutomationHour.com and AppXchangeHour.Com

      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.

    1. Yes, but in a few weeks 🙂

  7. 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 ReplyCancel reply

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

Discover more from Automation Champion

Subscribe now to keep reading and get access to the full archive.

Continue reading

Exit mobile version
%%footer%%