Customer Insights, Dynamics 365 Marketing, Journey, Power Automate

Send an email when a contact submits a form in Customer Insights – Journeys

A customer of mine is moving from outbound to real-time marketing and is creating new forms in RTM. In outbound they have had a Power Automate Flow created to send them a notification every time a new form submission comes in the system, so we wanted to copy that over to RTM, it shouldn’t be much of an issue, just copy and change the table that triggers it, right, riiiiight….? Well, it was an issue or lots of issues. But this is how I solved it, with absolutely no code or formulas or complicated variables. So this post is for everyone (hello future myself when I’ve forgotten how to) who wants to send an email to someone when a contact (or lead) submits a form in real-time marketing in Customer Insights – Journeys.

Because the new interface is out for Power Automate (at least in make.powerautomate.com, if you open the flow from make.powerapps.com you get the old interface) I’ll be showing screenshots from both versions to make it easier to follow along no matter which interface you use.

Result

I’m going to start by showing you what I wanted to get from this flow. The picture is the email with all the content I wanted to get from the submission.

The subject is the name of the form and the full name of the contact who filled in the form.

The body is the full name of the contact, the email of the contact, the name of the form, and the date the contact submitted the form.

I wanted this email to be sent to the user who owns the contact in Dataverse.

Screenshot of an email with text from the flow
Screenshot of the email

The form and submission

I’ve created the form as any form in RTM.

Screenshot of the form in RTM
The form in RTM

When you fill in the form and submit it, you create a form submission in Dataverse/Customer Insights – Journeys.

Screenshot of the form submission in Dataverse/Customer Insights - Journeys with all the columns
The form submission in Dataverse/Customer Insights – Journeys

Now we can see how it’s connected and we shouldn’t have much trouble getting the flow working.

Trigger

The first thing to select is the trigger. This is what will get your flow to start. For this, you want to find “Form Submissions” as the table, change type set to “Added”, and set the scope to “Organization” (you always want it to trigger).

Now that’s the easy part. We can trigger the flow every time a form is submitted (some of you will probably want to put some filters in here, but for my customer, they wanted notifications for all forms).

Actions – get everything

Now it’s time to get all the tables which contain information you want to use in the email. This part got bigger than I expected, with a nasty little surprise! For all my actions I’m using the Dataverse connector and the “Get a row by ID”, with this I just get the one record I’m looking for and not multiple that I need to filter.

Get form submissions

First, we need to get the actual form submission. The table is “Form Submissions” and the Row ID is “Form Submission ID”. The form submission contains most of the references we need to get the other tables we need.

Get form

Now we want to get the form so we can use the name of the form that was submitted in the email. The table is “Forms” and the Row ID is “Form(Value)” from the get form submissions action.

Get entity link

Now this is the one that frustrated me and I didn’t understand. I thought I could get the contact directly from the form submission and didn’t understand why I was getting the wrong GUID or a blank value, I knew there was something there, I could see it in the system, but I couldn’t understand the connection until I found out that there was a intersect table connecting the submission and the contact. So I had to get the table “Created entity link” to be able to later get the contact. The Row ID here is “Linked Record (Value)” from the new form submissions.

Get contact

After we get the created entity link, we can finally get the contact to use the columns from the contact table. The table is “Contacts” and the Row ID is “Target Entity ID” from the get entity link action.

Get user

The last table we need to get is the user, we want to send the email to the owning user of the contact, to inform them that their contact has submitted a form.

The table is “Users” and Row ID is “Owning User (Value)” from the get contact action.

Send an email to the owner of the contact

Now it’s finally time to create the email we want to send. I’m using the Send an email (V2) with the Office 365 connector.

In the To field I put the primary email from the get user action.

Subject has a reference to the name of the form from the get form action and the full name of the contact from the get contact action.

The body of the email has the name and primary email from the get contact and the name of the form from the get form action. In addition to this I want to see when the form submission is created, and for that we’ll use som magic from Power Automate.

Showing a proper date

I want to show when the form submission was created, but if I choose the out-of-the-box “created on” column, it will give me a hard-to-read date format. So now it’s time for functions, don’t worry, we won’t write a single function for this, the system will do everything for us! I could only find this functionality in the old interface, so these screenshots will all be from that.

First I go to add dynamic content and click on “Format data by examples”

Expressions and format data by examples

Now I get another window where I choose “Created on” from the new form submission is created action.

screenshot from where I select created on from New form submission is created
Created on from New form submission is created

I now get to create some example values, this is the value I get from the “Created on” column and put in the desired output, the way I would like it to come to the email. I know what the standard output from “Created on” looks like because I’ve tested it in an email and wasn’t fond of how it looks (2023-12-07T10:27:27Z).


Provide example and desired output and get the expression

After you’re satisfied with this, you click apply and it will paste the expression for you and it will show the date the exact way you want.

Your flow will look like this once it’s finished

Now you can trigger the Power Automate and it will send an email to the owner of the contact who submitted a form.

1 thought on “Send an email when a contact submits a form in Customer Insights – Journeys”

Leave a comment

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