Microsoft Power Automate | Cognito Forms

Overview

This blog will provide a brief introduction to Power Automate (formerly called Microsoft Flow) and Cognito Forms and will demonstrate an integration between Microsoft Dynamics 365 CRM solutions (otherwise known as CE) and Cognito Forms using Power Automate.

Power Automate is a powerful cloud-based service that allows us to build automated workflows, connecting two or more otherwise separate applications. If you are familiar with Dynamics 365 workflow processes, you can envision Power Automate mirroring that type of functionality, plus a whole lot more. One of the great benefits of Power Automate is that it is not restricted to a particular individual application, but rather it joins applications.

Cognito Forms is an easy-to-use online form builder in which the created form may be embedded into an existing website to collect user data. Cognito provides several features with their forms, ranging from dynamic calculations, conditional logic, to data encryption. Check them out here.

The Need

One of our clients presented a need to integrate Cognito Forms and Dynamics 365 for Sales (D365). The client collects various sets of user information, but it mainly surrounds general contact information. They had the desire to capture this information in their D365 system to begin the lead-to-sales opportunity business process.

The Solution

This blog will only cover the Power Automate portion; it will not cover the creation of the form in Cognito.

Here is the overall solution execution process:

  • User fills out embedded Cognito Form on client website
  • Cognito Form triggers Power Automate
  • Power Automate creates a new D365 lead record, mapping the necessary fields

And here is a summary of Power Automate tasks to complete:

  • Create new Cognito Forms to D365 Power Automate
  • Identify trigger
  • Enter Cognito credentials
  • Complete trigger
  • Create new D365 lead record
  • Map all necessary fields
    1. Set D365 Country lookup field based on user input from a HTML dropdown list
  • Create note and attach to lead

Lucky for us Power Automate has connectors for D365 and Cognito Forms.

Create New Cognito Forms to Dynamics 365 From Power Automate

Log into the desired D365 environment and then navigate to Power Automate by clicking on the Office 365 icon at the top left.

Cognito-Forms Cognito-Forms

This will redirect to the Power Automate site. If you want to retain your D365 environment in a separate browser tab, duplicate the browser tab first.

Click My Flows in the left navigation.

Cognito-Forms

If you attempted to create a flow from a template, you will discover that there is not a template for Cognito Forms to D365.

Cognito-Forms

We will have to create our flow from scratch. Click New – Create from blank at the top left to create a new Power Automate.

Cognito-Forms

Scroll to the bottom of the page and click the search link.

Cognito-Forms

This will redirect you to the Connector search page.

Identify Trigger

Since Cognito Forms will be the trigger to our flow, search for Cognito Forms.

Cognito-Forms

Click “When a new entry is created.”

Enter Cognito Credentials

As mentioned before Power Automate connects applications. In order for that to happen, we need credentials which will be utilized when applications are accessed.

Cognito-Forms

Follow the credential-entry process.

Cognito-Forms

You will be required to authorize the designated organization to share information. Click the “Authorize Organization” button.

Cognito-Forms

Complete Trigger

After entering credentials for the flow trigger, you will need to choose the correct Cognito Form. Here, we have selected “Contact an Expert.”

Cognito-Forms

It is recommended to name your flow components to easily-recognizable labels. Click the ellipses at the top right of the flow component and click Rename.

Cognito-Forms Cognito-Forms

Create New Dynamics 365 Lead Record

You will notice that you cannot save a flow without having at least one step; if you try to do so, you will receive this warning:

Cognito-Forms

Click New Step.

Cognito-Forms

Once clicked, the screen will change and display connector and action options.

Cognito-Forms

In the search, enter “Dynamics 365.” The list of options will change, and you will see D365-specific options. Scroll down and click “Create a new record.”

Cognito-Forms

We now have the ability to select the Organization Name which is the D365 CRM instance (production, UAT, or dev for example)

Cognito-Forms

Rename component name.

Cognito-Forms

Map All Necessary Fields

The flow component will expand and show all fields available for mapping for the D365 lead entity. The D365 fields will be displayed on the left, and when a field is selected, the Cognito Form fields will be displayed on the right.

Cognito-Forms

Now we begin the process of mapping the Cognito Form fields to the D365 lead fields.

This blog will only address a few of the D365 field types and provide instructions and options for mapping.

Single Line of Text

This is the easiest type of field to map; you simply click inside the D365 form field and find the Cognito Form field that matches, and you select it.

D365 Last Name field

Cognito-Forms

Cognito Form Last Name field

Cognito-Forms

If by chance you don’t see any Cognito fields, ensure the “Dynamic Content” tab is selected.

Cognito-Forms

You will have the ability to search Cognito fields. If there are many fields of which to choose, this will make it easier for selection.

If you desire to concatenate a number fields, add desired text before and after Cognito Form fields.

Cognito-Forms

Multiple Lines of Text

Multiple Lines of Text fields follow the same process.

Two Option

At some point, you most likely will need to fill a D365 Two Option field. This type of field is not a direct point-and-select process as the data types are handled differently between D365 and Cognito (HTML web forms). Here we need to add some Power Automate logic.

Selecting the correct D365 form field is the first task. In this scenario, we need this field.

Cognito-Forms

After clicking into the field, we are presented with some options.

Cognito-Forms

Since we need to collect data in which the website user entered, we will select “Enter custom value.”

Immediately this box will appear to the right.

Cognito-Forms

Select “Expression.” The following function box will appear.

Cognito-Forms

Some of you may have feelings of abandoning Power Automate because you don’t want to program or don’t know anything about programming. But good chances are someone has met the challenge that is in front of you and has provided some instructions on the Internet.

In addition, the Power Automate tool will assist in your developing functions with IntelliSense. As you type into the function box, Power Automate will provide choices. For example, in this illustration, I entered the following:

Cognito-Forms

I clicked inside the brackets and then switched from Expression tab to the Dynamic Content tab. This allows me to select the correct Cognito Form field.

Cognito-Forms

Now I add the following:

Cognito-Forms

We now have a HTML radio option mapped to a D365 Two Option field. If the user selects the “Yes” radio option, the D365 true/Yes Two-Option value will be entered; otherwise the false/No Two-Option value will be entered.

Option Set

Here we will discover three ways to set an Option Set value.

The first way to set an Option Set is to select one of the given choices.

Cognito-Forms

Another way is to enter the D365 Option Set value.

Cognito-Forms

You can grab the Option Set value by navigation to the solution, entity, and field.

Cognito-Forms

The last way I’ll show how to set an Option Set value is through Power Automate logic.

Cognito-Forms Cognito-Forms

Lookup

Hard-Code Approach

Similar to setting an Option Set value, we can set the Lookup value with a hard-coded GUID or through MS logic.

NOTE – This is not the best approach, and it is not recommended if you plan on using the flow across D365 environments. However, if your scenario fits, go right ahead. For example, you may have only one D365 environment and therefore are not concerned with GUID variances across D365 environments.

You can hard code the GUID value.

Cognito-Forms

To find the GUID value of a record, you can use Advanced Find. Build your query, ensuring you select the record you desire. Click Download Fetch XML and open up in Notepad or Notepad++.

Cognito-Forms

Grab the GUID value; take everything inside the curly braces.

Cognito-Forms

Power Automate Logic

You can also use Power Automate logic to set a lookup field.

Cognito-Forms

List Records (Set D365 Country lookup field based on user input from a HTML dropdown list)

Another way to set a D365 Lookup field is through the Power Automate List Records process. Here’s how you do it.

  1. Click New step
  2. Search for Dynamics 365
  3. Select List records
  4. Select Organization Name
  5. Select Entity Name
Cognito-Forms

To complete this, you will need the Name of the field. Retrieve by navigating to Settings – Customizations – Customize the System – Expanding Entities – Expanding Fields

Cognito-Forms

In the Filter Query field back in Power Automate, enter the Name value along with eq ‘’. Click inside the single quotes, ensure Dynamic Content is showing on the right, and select the desired Cognito Form field.

Cognito-Forms

The single quotes are quite important; without them the flow will not successfully complete. The reason is because we are implementing programming logic, albeit through the Power Automate logic visual interface.

Because Country is a string-type field and placed inside programming logic, it needs to be surrounded by quotes. Essentially, we are writing this:

IF enc_name = ‘Dynamic Country Value’ THEN

We are ready for the next step: applying the action when a Country is a match.

  1. Click New step
  2. Click Control
  3. Select Apply to each
Cognito-Forms

Enter cursor into the field named Select an output from previous step and select value from the right.

Cognito-Forms

This is what we have so far:

Cognito-Forms

Inside the Apply to each component, select Add an action.

Cognito-Forms

Select Control and then select Condition from the list. This will expand the component to the following:

Cognito-Forms

Follow these steps to update the D365 Lead record to the correct Country:

  1. Click Add an action on the “If yes” side
  2. In the search box, enter “Dynamics 365”
  3. Select Update a record
  4. Select Organization Name
  5. Select Entity Name
  6. Click inside Record identifier field
  7. On right, select Lead [Unique identifier of the lead.]
Cognito-Forms

This is quite a process, but it ensures you have an up-to-date D365 value.

Create Note and Attach to Lead Record

The client required a web form text area field to be converted into a D365 note attached to the newly created lead record. Here are the steps.

  1. Click New Step
  2. Search Dynamics 365
  3. Select Create a new record
  4. Select Organization Name
  5. Select Notes for Entity Name
  6. Enter Title

I’ll pause here to mention that we wanted a consistent default value for Title, so I entered “How can I help you?”

  1. Select No for Is Document
  2. Select Lead [Unique identifier of the lead.]

Ensure Lead is selected from the Create New Lead Record section – the first flow component created.

Cognito-Forms

9. Select leads for Regarding Type

The list for Regarding Type is not in alphabetical order.

Once this is set, you are ready to test your Power Automate.

Enter data into the Cognito Form on the website.

Cognito-Forms

View the information in D365.

Cognito-Forms

Conclusion

This blog has demonstrated how to create a Power Automate to integrate Cognito Forms and Microsoft Dynamics 365 CRM solutions. To accomplish this on your own, you will need:

  • Credentials to all systems that need to be integrated
  • Familiarity with data

If you have any questions about using Power Automate with Dynamics 365, please contact us.

Dynamics 365 CE (CRM) How-To eGuide

41 pages of step-by-step instructions for 6 different key tasks in Dynamics 365 Customer Engagement (CRM). Includes interactions with PowerApps and Flow!

Get the eGuide

Dynamics 365 CE (CRM) How-To eGuide

Get the eGuide