Suppose you have a set of records and you want to insert them into an email message. To do this, you can use the updated GenerateCustomReport action to generate a chunk of HTML suitable for adding to the Body of an email action that supports rich text, like Send Rich Email.
You pass in a comma-separated list of the fields you want to show in the table. Make sure to use the full api names, including ‘__c’ for custom fields.
You can also decide whether or not to show a Header row with the names of your fields.
You can style your table. The styling support is powerful but primitive. You can pass in a css Style string for each of three sections: the overall Table, the Header, and the Rows. Because style strings are a little fussy, I like to use Text Templates for them.
Here’s a sample configuration:
Here’s an example of styled output on a Flow Screen:
Keep in mind that if you want to provide the data in a form on the flow screen that can be manipulated, selected, sorted, etc, you should instead use the Datatable component. The action described here is mainly intended for when you want to output the data through email or into a Quip page.
You can add styling information directly to an input, or put it in a Text Template and pass the Text Template into the input. Here’s an example of one of the Text Templates used to generate the above table:
This is conventional css, and everything you can do in a <style> html tag is available to you. For more information on styles you can use, consult a resource like W3Schools.
Usage Note: if you use Text Templates, you MUST change the menu button from View as Rich Text to View as Plain Text before making any change to your text. If you don’t extra html tags will be inserted and your formatting won’t work properly. We’re working on a fix for this.
Using with Email
Finally, here’s the result in an email message:
In this case, I’ve simply routed the output from my action to the HTML Body input of the Send Rich Email action:
Note that you can use another Text Template to provide boilerplate text:
And the email result is:
The key concept to understand is that at the end of the day, a rich email body is just a single string full of html tags. Each instance of this action will spit out one such string, and the text templates also spit out strings. You can combine them together using formulas or another text template (see the video for an example of this) or an Assignment element.
Creating Headers and Parent/Child Reports
You can combine multiple instances of this action to create richer report structures. Here’s an example that uses an output string from an Account record and a second output string from a collection of Contact records:
To accomplish this effect, the HideHeader input is set to true on the parent Account Generate Collection Report action and it’s given a font-size style string to make it larger. On the second Generate Collection Report action that displays the child contacts, the style ‘margin-left’ is applied at the table level (not the row level) to achieve the desired indentation:
See the above video for more information.
Working with Multiple Parent/Child Combinations
You can create a large report in Flow with many Parents that have many children, but you may have to take some steps to avoid triggering the 100 SOQL Queries Limit, because you need to carry out a Contact query for each Account and this normally will all be done in a single transaction. If your parent list is around 100 records or larger, you’ll need to break up your flow from a transaction point of view. To solve this, the flow below uses the ‘new’ Commit Transaction action which forces the transaction to close on each iteration through the loop:
This allows you to create large reports:
Be aware, though, that bypassing the normal transaction unification process in this way can result in flows that take a long time to run.
This action is part of the Collections Action package and the features described here are available starting in version 1.18 of that package.