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.
We need to use “xml” and “xpath” functions to read and parse XML in Power Automate.
Eg. xpath(xml(Output(‘XML’)), ‘/rootnode/items’)
Below are the steps to read and parse XML and create the Account records using Power Automate:
- We need to prepare standard structure of XML before creating power automate because we need to parse XML based on the format we have.
- 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.
<accounts>
<account>
<accountname>Royal Acc Ltd.</accountname>
<phone>1234567892</phone>
<website>royal.acc.in</website>
<street1>321, S. V. Road</street1>
<city>Mumbai</city>
<state>MH</state>
<revenue>500000</revenue>
</account>
<account>
<accountname>MangloreAcc Ltd.</accountname>
<phone>7487596145</phone>
<website>manglore.acc.in</website>
<street1>147, VrundavanSociy</street1>
<city>Manglore</city>
<state>KA</state>
<revenue>1000000</revenue>
</account>
</accounts>
Step1: Create a Flow. Ihave created “Recurrence” flow which will trigger at 1 am every day.
Step2: Add new steps to get XML value form API.
Step3: Add compose variable to set output (response body) of Http Request.
Step 4: Use Xpath expression to read XML value
Expression:
xpath(xml(outputs(‘Set_Http_Response’)), ‘/accounts/account’)
Here: Set_Http_Response is the previous step name.
Step5: Use ‘Apply for each’ control loop to read multiple records and create the same in CRM.
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
Below are some Example:
Account Name = xpath(item(),’string(account/accountname)’)
Address 1 : City = xpath(item(),’string(account/city)’)
Step 6: Save and Run Power Automate. We will get the below response body in HTTP request.
Output:
Conclusion
We can create multiple records in Power Automate using XML Data.