How to include child records in Dynamics 365 Email Templates
Introduction
One of the limitations of Dynamics 365 Email Templates is the inability to include child records as dynamic content. Take for example an Email Template for a Quote. Out of the box it is not possible to include a list of Quote Products related to a Quote. This post will show you how, with a bit of creativity, you can include child records in a standard Email Template. In brief we’re going to create a rich text field on the table we want to create the Email Template for. We’ll use Power Automate to create a HTML table. This HTML table will then be stored in the rich text column. Once done we’ll add that rich text column as a dynamic content field in a standard Email Template 👍.
Prerequisites
Whilst this solution is “low-code” you will need to be familiar with creating Power Automate Flows.
Create a new Rich Text column
On the table you wish to create an Email Template for, create a new Rich Text column as shown below. It is within this Rich text column that we’re going to store the list of child records.
Create a new Power Automate Flow
We now need to create a Power Automate Flow to populate this Rich text column. The Flow trigger will vary depending on your requirements. For this example I’m going to repopulate the newly create Quote Products Table column each time the Quote Total Amount changes, which happens each time a product is added, removed or had its pricing updated. Alternatively you could make this a manually triggered Flow and require users to run the Flow before an Email Template is generated.
The second step in the Flow is to retrieve the related Quote Products.
Next we need to create a HTML table from the results.
Finally save the Output of the Create HTML table action back in the Rich text field created in the earlier step.
Create an Email Template
Next up let’s create an Email Template for the Quote table.
Next up draft an email and add the Rich text column as a dynamic text column as you would any other column.
Use your Email Template
Finally head over to the table you created the Email Template for. Create an Email and insert the Email Template.
Adjust the table formatting
Right, so we’ve proved that you can indeed include child items in an Email Template with a little bit of Power Automate creativity. Let’s now format the table values a bit to make it look more professional. Back in the Flow I’ll replace the values in the Create HTML table with the Price and Amount formatted values.
Conclusion
Despite the out of the box technical limitation of not being able to include child records in Email Templates, in this post we looked at a low-code workaround utilising Rich text columns and Power Automate.