Microsoft Power Automate | Cognito Forms
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.
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.
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
- 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.
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.
If you attempted to create a flow from a template, you will discover that there is not a template for Cognito Forms to D365.
We will have to create our flow from scratch. Click New – Create from blank at the top left to create a new Power Automate.
Scroll to the bottom of the page and click the search link.
This will redirect you to the Connector search page.
Since Cognito Forms will be the trigger to our flow, search for 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.
Follow the credential-entry process.
You will be required to authorize the designated organization to share information. Click the “Authorize Organization” button.
After entering credentials for the flow trigger, you will need to choose the correct Cognito Form. Here, we have selected “Contact an Expert.”
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.
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:
Click New Step.
Once clicked, the screen will change and display connector and action options.
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.”
We now have the ability to select the Organization Name which is the D365 CRM instance (production, UAT, or dev for example)
Rename component name.
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.
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 Form Last Name field
If by chance you don’t see any Cognito fields, ensure the “Dynamic Content” tab is selected.
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.
Multiple Lines of Text
Multiple Lines of Text fields follow the same process.
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.
After clicking into the field, we are presented with some options.
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.
Select “Expression.” The following function box will appear.
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:
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.
Now I add the following:
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.
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.
Another way is to enter the D365 Option Set value.
You can grab the Option Set value by navigation to the solution, entity, and field.
The last way I’ll show how to set an Option Set value is through Power Automate logic.
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.
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++.
Grab the GUID value; take everything inside the curly braces.
Power Automate Logic
You can also use Power Automate logic to set a lookup field.
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.
- Click New step
- Search for Dynamics 365
- Select List records
- Select Organization Name
- Select Entity Name
To complete this, you will need the Name of the field. Retrieve by navigating to Settings – Customizations – Customize the System – Expanding Entities – Expanding Fields
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.
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.
- Click New step
- Click Control
- Select Apply to each
Enter cursor into the field named Select an output from previous step and select value from the right.
This is what we have so far:
Inside the Apply to each component, select Add an action.
Select Control and then select Condition from the list. This will expand the component to the following:
Follow these steps to update the D365 Lead record to the correct Country:
- Click Add an action on the “If yes” side
- In the search box, enter “Dynamics 365”
- Select Update a record
- Select Organization Name
- Select Entity Name
- Click inside Record identifier field
- On right, select Lead [Unique identifier of the lead.]
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.
- Click New Step
- Search Dynamics 365
- Select Create a new record
- Select Organization Name
- Select Notes for Entity Name
- 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?”
- Select No for Is Document
- Select Lead [Unique identifier of the lead.]
Ensure Lead is selected from the Create New Lead Record section – the first flow component created.
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.
View the information in D365.
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.
41 pages of step-by-step instructions for 6 different key tasks in Dynamics 365 CRM apps. Includes interactions with Power Apps and Power Automate!