How To Email Related Records in Tabular Format from Flow

Salesforce Email Related Records in Tabular Format

Acknowledgement: The full credit for this blog post goes to Amruta Udgiri, one of our course participants, for sharing her idea on how to email related records in tabular format from Flow.

One of the common requirements in a Salesforce implementation is to email a list of related records like cases, invoices, payment statuses etc. to customers in a nicely formatted email.

With Classic Email Template, we used Visualforce to meet such requirements. In Flow there is a native “Send Email” Action.

In this guide we are going to look at how to use the send email action with a couple of other Flow features to retrieve the list of records based on certain filter condition, format the list nicely in a HTML table and email it to the one of the selected contacts. All this in just under 30 minutes. But let’s first take a look at the end result of what we will be building.

And here is the step by step guide to build what we just saw. Let’s dive in.

NOTE: Certain sections of the guide will appear as locked in the free preview. You can download the unlocked version of the guide in PDF format by subscribing to our “All Access” Pass through the link below.

Not an “All Access” Pass Member Yet?

Get Download Access to this & 150+ More Step-by-Step Guides with “All Access” Pass. A simple and single plan to access our entire library of courses, guides, workshops & masterclasses on Salesforce.

Introducing Mastering Salesforce Flows Training Course

Liked this post? We are now offering a complete self-paced, video-based training course on Mastering Salesforce Flows. The course comes with downloadable step-by-step PDF guides, unlimited access, free upgrades, community discussion area, free preview and more. For more details, please click here.

Need Help with Flows?

Need advice on Flows? I also offer advisory & consulting services on Salesforce Flows. So, whether you want to create new Flows or migrate existing automations (Workflow Rules, Process Builder, Triggers) to Flows, I can help you analyze, design, plan & review. To initiate a discussion, please submit the contact form here stating your requirement or schedule a discussion at this URL.

References & Useful URLs

22 thoughts on “How To Email Related Records in Tabular Format from Flow”

  1. Hi Ashish,

    For me the values are coming as blank and when I am debugging I can see only html tags in it but not the values. This is inside the loop and I can see the records are coming and they have the values. But not coming in text template variable.

    1. Hi Vinay, are you using this guide as-is or have you changed the values as per your requirement? If you have changed the values, it may be worthwhile to try configuring everything as shown in the guide. That will at least tell you whether this is working in your environment or not. You can then tweak it based on your requirements.

  2. What would cause the table information not to get imbedded in the Email Body? If I follow your instructions to a tee, it works but if I modify for my needs… the table data will not display in the email. When I debug, I can see the info getting assigned to the variable but will not find it’s way into the email body. Even the tags from the loop make it… the content will not. Working with Opportunities and Product Items.

    1. Hi Tim, one of the reasons that I can think of is that the HTML code may not be right. You can use the “Debug” option in Flow Builder, copy the html code, create a html file and paste the code. Then try to open that file in a browser. See if that displays the data.

  3. Found this super helpful and super simple instructions. 1 question I have is if I wanted the table design to look different in the email how could I achieve this for example, I want it to look like this:
    Name
    £Value | £Value | £Value

    Rather than:
    Name | £Value | £Value | £Value

    Is there a way to do this?
    Thanks,
    Michael

    1. Hi Michael, you will need to experiment with the resource type of “text template” and HTML as shown in this guide to see if that would be possible. Theoretically it should be possible.

  4. I’m trying to build this on the Opportunity object. I would like to Get the Opportunity record before the Account record. I’ve added it in but when I start the flow on the Opportunity no Contacts are populating.

    1. Hi Janelle, if you are starting the Flow on Opportunity record, you must be passing the Opportunity Record ID to the flow. From opportunity you need to get the Account Record ID and then get the contacts based on the Account record ID. This could be the issue.

  5. Hi Ashish

    As usual, love it thanks! Can’t wait to try it out!

    Is there a possible final step to record the email sent as an email message for visibility?

    Cheers
    Nic

    1. Thanks Nic. Glad that you liked it. Currently, there isn’t an out-of-the functionality to record the email. But what I have done in my org is explicitly create a ‘Task’ record for the contact and store the email subject and body in the task record. Prefix the task subject with ‘Sent Email: ‘. See if this will work for you.

  6. Ashish,
    This new button is fantastic and works great for me (System Administrator).
    But when I log in as one of my users, I do not see the new button. I have even stood beside a user when he was in Lightning – no new button.
    Any suggestions?
    Please let me know if you’d prefer me to submit a case with Salesforce. I’ll understand.
    Many thanks.

    1. Hi Larry, here are the things you can check.

      1. Is the button added using Dynamic Action? Is there any filter condition attached to the button?
      2. Does the user have ‘Run Flow’ system permission?

  7. Ashish,
    As a temporary solution for adding BCC: sending user, I created the following formula which includes both the selected contact AND sending user as To recipients.

    {!SelectContact.firstSelectedRow.Email} + ‘,’ + {!$User.Email}
    For my purposes, this is a viable option. I am really loving this FLOW and will definitely build upon it with other uses.
    Thanks again.

  8. YES – Deliverability. I remembered that and wanted to let you know that was my problem.

    Is there any way to include a BCC: to the sender
    OR
    Create an Activity History of the sent email

    1. Hi Larry,

      1. Currently there isn’t an option to send BCC from ‘Send Email’ action in Flow. However, under set up, there is an option ” Compliance BCC Email “, which will send a bcc to all the emails sent from Salesforce.
      2. Emails sent from Flow will not create an activity history record. But you can explicitly “create” a task record in the Flow to create the activity history. I do this in a couple of my Flows. 🙂

      Regards,
      Ashish

  9. I love the step-by-step tutorial. However, up through page 21 I’m good.
    Page 22 I’m derailed! I do not see the Component Input (1) – Data Table in order to drag it to the canvas.

    Did I miss something along the way?

      1. Thanks Ashish.
        The sandbox I was using on Oct. 14 was just upgraded to Winter ’23 on Oct. 15th.
        I have the Data Table now, completed creating the FLOW and did my first test.
        Even though I got the Confirmation screen, I have not received the actual email.
        I’m reviewing everything from the beginning.
        Thanks again.

Leave a Comment

Your email address will not be published. Required fields are marked *

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

Scroll to Top
Introducing All Access Pass