{"id":27351,"date":"2021-03-15T11:12:54","date_gmt":"2021-03-15T11:12:54","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=27351"},"modified":"2023-03-17T11:20:20","modified_gmt":"2023-03-17T05:50:20","slug":"parse-xml-in-power-automate-and-create-records-in-dynamics-365-crm","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2021\/03\/parse-xml-in-power-automate-and-create-records-in-dynamics-365-crm\/","title":{"rendered":"Parse XML in Power Automate and Create records in Dynamics 365 CRM"},"content":{"rendered":"<h2><strong>Introduction<\/strong><\/h2>\n<p>In Dynamics 365, we can create multiple records through the OOB Import method, by using SSIS Package. In this blog, I will show how to create multiple records from XML using power automate.<\/p>\n<p>Microsoft introduces many new functions, which we can use in Power Automate. Please find the below reference link of the functions.<\/p>\n<p><a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/logic-apps\/workflow-definition-language-functions-reference#xpath\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/docs.microsoft.com\/en-us\/azure\/logic-apps\/workflow-definition-language-functions-reference#xpath<\/a><\/p>\n<p>We need to use \u201cxml\u201d and \u201cxpath\u201d functions to read and parse XML in Power Automate.<\/p>\n<p><strong>Eg. <\/strong>xpath(xml(Output(&#8216;XML&#8217;)), &#8216;\/rootnode\/items&#8217;)<\/p>\n<p>Below are the steps to read and parse XML and create the Account records using Power Automate:<\/p>\n<ul>\n<li>We need to prepare standard structure of XML before creating power automate because we need to parse XML based on the format we have.<\/li>\n<li>I have created API function to get XML in Power Automate(below is the sample XML value), so accordingly I will write an expression to parse XML in power automate.<\/li>\n<\/ul>\n<p>&lt;accounts&gt;<\/p>\n<p>&lt;account&gt;<\/p>\n<p>&lt;accountname&gt;Royal Acc Ltd.&lt;\/accountname&gt;<\/p>\n<p>&lt;phone&gt;1234567892&lt;\/phone&gt;<\/p>\n<p>&lt;website&gt;royal.acc.in&lt;\/website&gt;<\/p>\n<p>&lt;street1&gt;321, S. V. Road&lt;\/street1&gt;<\/p>\n<p>&lt;city&gt;Mumbai&lt;\/city&gt;<\/p>\n<p>&lt;state&gt;MH&lt;\/state&gt;<\/p>\n<p>&lt;revenue&gt;500000&lt;\/revenue&gt;<\/p>\n<p>&lt;\/account&gt;<\/p>\n<p>&lt;account&gt;<\/p>\n<p>&lt;accountname&gt;MangloreAcc Ltd.&lt;\/accountname&gt;<\/p>\n<p>&lt;phone&gt;7487596145&lt;\/phone&gt;<\/p>\n<p>&lt;website&gt;manglore.acc.in&lt;\/website&gt;<\/p>\n<p>&lt;street1&gt;147, VrundavanSociy&lt;\/street1&gt;<\/p>\n<p>&lt;city&gt;Manglore&lt;\/city&gt;<\/p>\n<p>&lt;state&gt;KA&lt;\/state&gt;<\/p>\n<p>&lt;revenue&gt;1000000&lt;\/revenue&gt;<\/p>\n<p>&lt;\/account&gt;<\/p>\n<p>&lt;\/accounts&gt;<\/p>\n<p><strong>Step1<\/strong>: Create a Flow. Ihave created \u201cRecurrence\u201d flow which will trigger at 1 am every day.<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/1-Parse-XML-in-Power-Automate-and-Create-records.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter wp-image-27358 size-full\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/1-Parse-XML-in-Power-Automate-and-Create-records.png\" alt=\"Parse XML in Power Automate and Create records\" width=\"642\" height=\"231\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/1-Parse-XML-in-Power-Automate-and-Create-records.png 642w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/1-Parse-XML-in-Power-Automate-and-Create-records-300x108.png 300w\" sizes=\"(max-width: 642px) 100vw, 642px\" \/><\/a><\/p>\n<p><strong>Step2:<\/strong> Add new steps to get XML value form API.<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/2-Parse-XML-in-Power-Automate-and-Create-records.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter wp-image-27359 size-full\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/2-Parse-XML-in-Power-Automate-and-Create-records.png\" alt=\"Parse XML in Power Automate and Create records \" width=\"633\" height=\"288\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/2-Parse-XML-in-Power-Automate-and-Create-records.png 633w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/2-Parse-XML-in-Power-Automate-and-Create-records-300x136.png 300w\" sizes=\"(max-width: 633px) 100vw, 633px\" \/><\/a><\/p>\n<p><strong>Step3:<\/strong> Add compose variable to set output (response body) of Http Request.<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/3-Parse-XML-in-Power-Automate-and-Create-records.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter wp-image-27361 size-full\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/3-Parse-XML-in-Power-Automate-and-Create-records.png\" alt=\"Parse XML in Power Automate and Create records \" width=\"663\" height=\"207\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/3-Parse-XML-in-Power-Automate-and-Create-records.png 663w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/3-Parse-XML-in-Power-Automate-and-Create-records-300x94.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/3-Parse-XML-in-Power-Automate-and-Create-records-660x206.png 660w\" sizes=\"(max-width: 663px) 100vw, 663px\" \/><\/a><\/p>\n<p><strong>Step 4: <\/strong>Use Xpath expression to read XML value<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/4-Parse-XML-in-Power-Automate-and-Create-records.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter wp-image-27357 size-full\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/4-Parse-XML-in-Power-Automate-and-Create-records.png\" alt=\"Parse XML in Power Automate and Create records \" width=\"935\" height=\"293\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/4-Parse-XML-in-Power-Automate-and-Create-records.png 935w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/4-Parse-XML-in-Power-Automate-and-Create-records-300x94.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/4-Parse-XML-in-Power-Automate-and-Create-records-768x241.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/4-Parse-XML-in-Power-Automate-and-Create-records-660x207.png 660w\" sizes=\"(max-width: 935px) 100vw, 935px\" \/><\/a><\/p>\n<p><strong>Expression: <\/strong><\/p>\n<p>xpath(xml(outputs(&#8216;Set_Http_Response&#8217;)),\u00a0&#8216;\/accounts\/account&#8217;)<\/p>\n<p>Here: Set_Http_Response is the previous step name.<\/p>\n<p><strong>Step5: <\/strong>Use \u2018Apply for each\u2019 control loop to read multiple records and create the same in CRM.<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/5-Parse-XML-in-Power-Automate-and-Create-records.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter wp-image-27356 size-full\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/5-Parse-XML-in-Power-Automate-and-Create-records.png\" alt=\"Parse XML in Power Automate and Create records \" width=\"896\" height=\"405\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/5-Parse-XML-in-Power-Automate-and-Create-records.png 896w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/5-Parse-XML-in-Power-Automate-and-Create-records-300x136.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/5-Parse-XML-in-Power-Automate-and-Create-records-768x347.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/5-Parse-XML-in-Power-Automate-and-Create-records-660x298.png 660w\" sizes=\"(max-width: 896px) 100vw, 896px\" \/><\/a><\/p>\n<p>In these steps, we need to map the column which we want to populate data in Account from XML node values, using xpath() in expression<\/p>\n<p>Below are some Example:<\/p>\n<p>Account Name = xpath(item(),&#8217;string(account\/accountname)&#8217;)<\/p>\n<p>Address 1 : City = xpath(item(),&#8217;string(account\/city)&#8217;)<\/p>\n<p><strong>Step 6:<\/strong> Save and Run Power Automate. We will get the below response body in HTTP request.<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/6-Parse-XML-in-Power-Automate-and-Create-records.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter wp-image-27355 size-full\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/6-Parse-XML-in-Power-Automate-and-Create-records.png\" alt=\"Parse XML in Power Automate and Create records \" width=\"575\" height=\"414\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/6-Parse-XML-in-Power-Automate-and-Create-records.png 575w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/6-Parse-XML-in-Power-Automate-and-Create-records-300x216.png 300w\" sizes=\"(max-width: 575px) 100vw, 575px\" \/><\/a><\/p>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/7-Parse-XML-in-Power-Automate-and-Create-records.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter wp-image-27354 size-full\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/7-Parse-XML-in-Power-Automate-and-Create-records.png\" alt=\"Parse XML in Power Automate and Create records \" width=\"939\" height=\"127\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/7-Parse-XML-in-Power-Automate-and-Create-records.png 939w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/7-Parse-XML-in-Power-Automate-and-Create-records-300x41.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/7-Parse-XML-in-Power-Automate-and-Create-records-768x104.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/03\/7-Parse-XML-in-Power-Automate-and-Create-records-660x89.png 660w\" sizes=\"(max-width: 939px) 100vw, 939px\" \/><\/a><\/p>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p>We can create multiple records in Power Automate using XML Data.<\/p>\n<p>&nbsp;<\/p>\n<p><strong><em>Like the automated creation of records from XML, Power Automate can be used for several other use cases with the right insights and expertise<\/em><\/strong><br \/>\n<strong><em>Explore more use cases at <a target=\"\" rel=\"noopener\">Inogic- Professional Services<\/a>. Contact us at <a target=\"\" rel=\"noopener\">crm@inogic.com<\/a> to enable business transformation now!<\/em><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction In Dynamics 365, we can create multiple records through the OOB Import method, by using SSIS Package. In this blog, I will show how to create multiple records from XML using power automate. Microsoft introduces many new functions, which we can use in Power Automate. Please find the below reference link of the functions.\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2021\/03\/parse-xml-in-power-automate-and-create-records-in-dynamics-365-crm\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[16,1985],"tags":[2590,2171,1975,2589],"class_list":["post-27351","post","type-post","status-publish","format-standard","hentry","category-dynamics-365","category-power-automate","tag-canvas-apps-more","tag-dataverse","tag-power-automate","tag-top-blogs-of-2021-power-apps"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/27351","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/comments?post=27351"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/27351\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=27351"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=27351"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=27351"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}