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 be taking a look at this process and how to automate it using magic i.e – Microsoft Flow 💖
In today’s example, our scenario is going to be sending an email to a Contact any time they register for an event. The email will contain a list of events the Contact has registered for that are upcoming. We’re going to automate the entire process using Flow!
First things first, if you haven’t read my previous blog on 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’ll go ahead and create the trigger for our Flow. 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 flow 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. If you want more details on this, be sure to take a look at this blog post. 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 the Email Send has been created, we’re going to associate the contact in line with my previous blog on Relating Records.
Now to the magic! We’re going to loop through all of 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 takes some practice to get right, so stick with it!
Next we’ll 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’ll want to create a connection record between that Event Participation Record and the Email Sent itself:
This action will create the Connection records to the Email Send. From here, once you update the Email Send record and sent the email, the Freemarker will pick up the records and list out the values as defined in your email!
Now that we’ve learned how to send a ClickDimensions Email with data from any record, the possibilities are endless! What are you going to use this Flow for? I’d love to hear your applications!