In this blog you can learn how to create a Mulitpart XML document with Power Automate. This example is using the account Entity and creates a document for all “Accounts“.
First we have to create a Flow in Power Automate. This can be an Automatic or Manual Flow, started by a trigger like here.
Then we are creating and initialize a variable to build a custom XML for DocumentsCorePack.
Set the “converttopdf” value to “True” to create one single pdf file. “False” will create a docx instead.
If you use the SharePoint Integration to save your files, don´t forget to turn the option “Save to SharePoint” to “true“.
And then we use the Dataverse – List rows function to get the account ID for all Accounts.
Then the loop is used to build the XML for all Accounts. The XML has to look that way:
The Blue lines are the header and footer from the xml we need to create, the black line is the dynamic part (required for each document to create).
The template ID and Entity is static in this example.
The Entryid Account has to build as a function: Items (‘apply to each’)[accountid].
Please note: The red section is not part of the XML, just comments.
In the last step we append the End of the XML Tab and execute the Automergeworking item that creates the document.
If you want to save the created document to a custom path then do not use the CRM SharePoint integration. Therefore you have to add another step to your Flow.
The file content must be build as function (to convert it from base64 before).
That’s it! We appreciate your feedback! Please share your thoughts by sending an email to email@example.com.