So now that we’ve looked at how to send ClickDimensions emails using Flow, our next step is to send an email containing data from any record in Dynamics. They said it couldn’t be done, but I’m here to prove them wrong! We’re going to take a look at this process and how to automate it using magic (i.e. Microsoft Power Automate).

In this example, we are going to send an email to a contact any time they register for an event. The email will contain a list of upcoming events the contact has registered for. We’re going to automate the entire process using Power Automate.

First things first, if you aren’t familiar with the Relate Records action, be sure to create this flow within a solution. We will need this in order to access the Relate Records CDS action. Once you have that down, we can create the trigger. Because we’re going to be sending an email every time someone registers for an event, we’re going to use the “When a Record is Created” trigger:

If you only want this to run for specific events, you can add a condition in here. Otherwise, move on to retrieving the contact that registered for the event. We’re going to need data from that contact record later on. We can retrieve the contact from the Event Participation record that was just created as so:

Now we’re going to go and build out the email send. Just remember to associate the correct template with the email send! This template should contain FreeMarker that is going to reference the Event Participation entity. We are using the same FreeMarker as in the original blog post.

Now that the email send has been created, we’re going to associate the contact.

Now to the magic! We’re going to loop through all the contact’s Event Participation records and create connections for the ones that have a status of Registered. Use the List Records action:

The trick is getting this Fliter Query data correct. We want to list out all Event Participation records where the contact value on the Event Participation record is equal to the current contact we are working with. cdi_contactid is the logical name for the Contact field on the Event Participation record, so to pull the value from that field on the records we’re comparing we add _value to the logical name of the field. To compare it with something, we use the eq expression. We are able to use dynamic content to pull in the contact value. It can take some practice to get right, so stick with it!

Next, we will use the Apply to Each action to start looping through the list and checking to see if the record has a status of Registered:

If the list of records contains an Event Participation record with a status of Registered, we will want to create a connection record between that Event Participation record and the email sent:

Pay attention to this order!

This action will create the Connection records to the email send. From here, once you update the email send record as outlined in our previous blog and send the email, the FreeMarker will pick up the records and list out the values as defined in your email.