{"id":120,"date":"2022-01-04T11:54:50","date_gmt":"2022-01-04T11:54:50","guid":{"rendered":"https:\/\/blog.citrus-lime.com\/crmc\/?p=120"},"modified":"2022-01-04T11:54:50","modified_gmt":"2022-01-04T11:54:50","slug":"using-power-automate-to-integrate-microsoft-forms-with-dynamics-365","status":"publish","type":"post","link":"https:\/\/blog.citrus-lime.com\/crmc\/using-power-automate-to-integrate-microsoft-forms-with-dynamics-365\/","title":{"rendered":"Using Power Automate to Integrate Microsoft Forms with Dynamics 365"},"content":{"rendered":"\n<p><strong>Article by Jessica Corbett,\u00a0<\/strong><a href=\"https:\/\/www.crmcs.co.uk\/\"><strong>CRMCS<\/strong><\/a><strong>\u00a0Dynamics 365 Consultant<\/strong><\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" width=\"327\" height=\"274\" alt=\"Jess' Article Imagery for Linked-in and Website\" src=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/Jess-Article-Imagery-for-Linked-in-and-Website_2FC4CDFF.png\"><\/p>\n\n\n\n<p>PowerApps provides the framework to integrate data seamlessly across different Microsoft apps in real time, rather than having to export and import data, or copy data across manually. One effective application that I worked on was using automated Flow (Power Automate) to integrate Forms with Dynamics.<\/p>\n\n\n\n<p>We have a form where people can submit their contact details if they wish to be kept up to date with our monthly CRMCS Webinars. The aim of this job was to run a flow on the form submission, to check our database for a duplicate contacts, and if one existed then to update that contact, and if none existed then to create a new contact.<\/p>\n\n\n\n<p>In this article I\u2019m going to explain all the flow steps I used to get to this goal!<\/p>\n\n\n\n<p><strong>STEP 1 &#8211;&nbsp;<\/strong><strong>Get the details from the form submission<\/strong><\/p>\n\n\n\n<p>We want to trigger this Flow every time this particular Microsoft Form is submitted. To do this, we\u2019ll be:<\/p>\n\n\n\n<p>&#8211; Creating a new flow starting with \u2018Automated \u2013 from blank\u2019.<br>&#8211; Then name the Flow, and select the first trigger as \u2018When a new response is submitted\u2019 in the Microsoft Forms triggers.<br>&#8211; When you\u2019ve selected the form, select the data from the submitted form into your Flow.<br>&#8211; To do this, click add new step, and find \u2018Get response details\u2019 in the Microsoft Forms section.<br>&#8211; You can now fill in the \u2018Form Id\u2019 with the same form as in the first step, and then find the \u2018Response Id\u2019 from the dynamic content window from your first step.<br><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_1D7C073D.png\" alt=\"image\" title=\"image\" \/><\/figure>\n\n\n\n<p><strong>STEP 2 &#8211;&nbsp;<\/strong><strong>Initialise the variable<\/strong><\/p>\n\n\n\n<p>Next we want to \u2018Initialise a variable\u2019. This variable will essentially be a placeholder that we can increment as we search the database for duplicates, and will then dictate whether we need to create a new contact or not afterwards.<\/p>\n\n\n\n<p>Find \u2018initialise a variable\u2019 under the actions area in the flow step, give the variable a name, and then set this to 0.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_444A1D7D.png\" alt=\"image\" title=\"image\" \/><\/figure>\n\n\n\n<p><strong>STEP 3 &#8211;&nbsp;<\/strong><strong>Search the database for duplicate contacts<\/strong><\/p>\n\n\n\n<p>Now we need to search the database for any duplicate contacts, using the \u2018List records\u2019 action under the Common Data Service (current environment)\u2019 actions.<\/p>\n\n\n\n<p>Select the entity, then use the ODATA filter query field to specify what exactly you want to search on. (<em>I only want to search based on the same email address, so I\u2019m going to use the database field name and bring in the dynamic data from the form to make the following query: \u201cemailaddress1 eq \u2018[Email Address]<\/em>\u2019)<br><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_3D2AE105.png\" alt=\"image\" title=\"image\" \/><\/figure>\n\n\n\n<p><strong>STEP 4 &#8211;\u00a0Update any duplicate contacts<\/strong><\/p>\n\n\n\n<p>We now want to add 1 to our variable for any contact that the search finds, then also update that contact record to update a Boolean field for \u2018Webinar updates\u2019 to \u2018Yes\u2019.<\/p>\n\n\n\n<p>To do this, we need to:<\/p>\n\n\n\n<p>Use the&nbsp;<strong>\u2018Apply to each\u2019&nbsp;<\/strong>step control \u2013 this allows us to perform an action for each record the filtered query finds (if it finds any).<\/p>\n\n\n\n<p>Select this step, then find the dynamic content \u2018Value\u2019 from your \u2018List records\u2019 step, and then define your actions.\u00a0<em>(I\u2019m going to have two actions, one \u2018Increment Variable\u2019 \u2013 adds 1 to my pre-defined variable, and another \u2018Update a record\u2019 under the Common Data Service (current environment) to update the found contact record).<\/em><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_7CF4C78A.png\" alt=\"image\" title=\"image\" \/><\/figure>\n\n\n\n<p><strong><em>N.B the important thing to remember when updating a contact record is to set the Item ID to the \u2018Current item\u2019 from the \u2018Apply to Each\u2019 flow step.<strong><em>&nbsp;<\/em><\/strong><\/em><\/strong><\/p>\n\n\n\n<p><strong>STEP 5 &#8211;&nbsp;<\/strong><strong>If no duplicate is found, create a new contact<\/strong><\/p>\n\n\n\n<p>This flow will now run through the database and update any existing contact.<\/p>\n\n\n\n<p>The last step is where we\u2019ll create a new record, if no duplicate value is found. For this, we can use a condition step, to interrogate the variable.<\/p>\n\n\n\n<p>If the flow has not found any duplicates, then the variable I set should still be equal to 0. Therefore I\u2019m going to set a condition to say if the variable is greater than 0, then nothing should happen, and if it is not, then add a new action step \u2018Create a record\u2019 from the Common Data Service (current environment).<\/p>\n\n\n\n<p>From here, I chose \u2018Contacts\u2019 as the entity, and then mapped every form field to the relevant field in our contact entity, using the dynamic content panel, and setting any static fields as required.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_51B03083.png\" alt=\"image\" title=\"image\" \/><\/figure>\n\n\n\n<p><strong><em>N.B. If you have a dropdown field or a boolean (yes\/no) field in your entity that you want to fill in from the form, you need to add this in a particular way. We\u2019ve published another article detailing exactly how to do this here:\u00a0<a rel=\"noreferrer noopener\" href=\"https:\/\/www.crmcs.co.uk\/content\/using-multi-select-option-sets-in-flow-with-microsoft-forms.aspx\" target=\"_blank\">Using Multi-Select Option Sets in Flow with Microsoft Forms<\/a><\/em><\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\" \/>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/CRMCS-main-logo-OUTLINES-TRANSPARENT-1_00DC3070.png\" alt=\"CRMCS main logo OUTLINES TRANSPARENT (1)\" title=\"CRMCS main logo OUTLINES TRANSPARENT (1)\" \/><\/figure><\/div>\n\n\n\n<p><strong>We hope you found this technical article useful, visit our&nbsp;<a href=\"https:\/\/www.crmcs.co.uk\/\">Website<\/a>&nbsp;for more Technical Articles including Microsoft Teams, PowerApps Portals, Dynamics 365 Marketing and more\u2026<\/strong><\/p>\n\n\n\n<p><strong>CRMCS RELATED ARTICLES : Flow \u2013 Getting Stuck in for Dynamics 365&nbsp;<\/strong><a href=\"https:\/\/www.crmcs.co.uk\/content\/building-and-testing-a-flow-for-dynamics.aspx\"><strong>https:\/\/www.crmcs.co.uk\/content\/building-and-testing-a-flow-for-dynamics.aspx<\/strong><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Article by Jessica Corbett,\u00a0CRMCS\u00a0Dynamics 365 Consultant PowerApps provides the framework to integrate data seamlessly across different Microsoft apps in real time, rather than having to export and import data, or copy data across manually. One effective application that I worked on was using automated Flow (Power Automate) to integrate Forms with Dynamics. We have a<\/p>\n","protected":false},"author":43,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_price":"","_stock":"","_tribe_ticket_header":"","_tribe_default_ticket_provider":"","_tribe_ticket_capacity":"0","_ticket_start_date":"","_ticket_end_date":"","_tribe_ticket_show_description":"","_tribe_ticket_show_not_going":false,"_tribe_ticket_use_global_stock":"","_tribe_ticket_global_stock_level":"","_global_stock_mode":"","_global_stock_cap":"","_tribe_rsvp_for_event":"","_tribe_ticket_going_count":"","_tribe_ticket_not_going_count":"","_tribe_tickets_list":"[]","_tribe_ticket_has_attendee_info_fields":false,"footnotes":""},"categories":[3],"tags":[],"class_list":{"0":"post-120","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-crm"},"featured_image_src":null,"author_info":{"display_name":"jadesmith","author_link":"https:\/\/blog.citrus-lime.com\/crmc\/author\/jadesmith\/"},"_links":{"self":[{"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/posts\/120","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/users\/43"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/comments?post=120"}],"version-history":[{"count":1,"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/posts\/120\/revisions"}],"predecessor-version":[{"id":121,"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/posts\/120\/revisions\/121"}],"wp:attachment":[{"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/media?parent=120"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/categories?post=120"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/tags?post=120"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}