• Release History
  • Documentation
  • Back to www.mscrm-addons.com
  • Release History
  • Documentation
  • Back to www.mscrm-addons.com
home/Knowledge Base/DocumentsCorePack(DCP)/Build a Multipart XML flow that concatenates documents into one file

Build a Multipart XML flow that concatenates documents into one file

1363 views 0 Updated on May 17, 2023

In this article, we will walk through the process of creating a document package in Power Automate using an XML-based definition of the individual elements within the package.   

Example

We will be creating an example document package consisting of a document for each account in our system. The example package will consist of the following elements:

  1. A document that is generated based on a DocumentsCorePack template
  2. A file that is retrieved from SharePoint  
  3. A file that is retrieved from a note in Dynamics 365  

We will demonstrate how to include these elements and the XML behind them.

1. Generating a document from a template 

First, we must create a Flow in Power Automate. This can be an Automatic or Instant Flow, started by a trigger of your choosing.  

Upon creating a Flow, we would need to begin by creating and initializing a variable. This variable will hold our custom XML.  We will append additional XML to this variable throughout the example. 

initialize a variable in Flow
Figure 1: Define the variable that holds the XML definition of the package

With the variable created, we can proceed to append our XML to it.  To begin with, we will append the XML below.  The converttopdf property has been set to true, but this can be set to false if the document needs to be created as a docx. If you use Sharepoint Integration to save your files, the savetosharepoint property can be set to true. 

The XML is as follows: 

<doc><docparts converttopdf="true" savetosharepoint="true"> 
appending xml for our properties
Figure 2: Appending the properties

Next, we add our template.  The template, like our other elements, will be static.  This means we can just include the template’s GUID and entity in the XML.  This GUID comes from the MSCRM-ADDONS.com Template record inside our system. 

xml for template
Figure 3: Adding the XML for our template

To get the account ID for all accounts, we use the Dataverse – List rows function.  The Apply to each function is then used to append the XML shown in Value to the variable for each account record. 

function to get all accounts
Figure 4: Using a function to get all accounts

2. Adding a Sharepoint document 

Our Sharepoint document comes next.  You can include this by adding the Sharepoint URL to the docpart.  To get the Sharepoint URL, you must retrieve it from Sharepoint itself. 

xml for sharepoint document
Figure 5: The XML for our Sharepoint document

3. Adding a Note

Similar to the template above, the note is static as well, so we include its ID in the XML as well. 

xml for attached note
Figure 6: The XML for our Note

Finishing up 

Finally, we close out our XML variable by adding the needed ending tags. 

xml end tags
Figure 7: Closing our XML

To create the document, we would need one more step.  By adding the Create Multipart document (sync) step and including our variable, this allows for the document to be created upon executing the Flow. 

generating a document
Figure 8: Generating our document via ‘Create Multipart Document (sync) (V3)’

In case the created document should be saved to an alternate path, another step would need to be added.  Here, using Sharepoint as an example, you can set the URL, folder path, the file name and content.  Since the created document was the output of the previous step, the file name and content can be retrieved, giving direct access to the generated document package. 

saving to a sharepoint path
Figure 9: Saving a document to a different Sharepoint path

Below is the XML used in the Flow with placeholders inserted.  Please feel free to repurpose it for your own Flows! 

<doc>
   <docparts converttopdf="true" savetosharepoint="true">
     <docpart template="TEMPLATE" entity="ENTITY" entityid="ENTITYID"></docpart>     
     <docpart SharePointUrl="SHAREPOINTURL"></docpart>
     <docpart Note="NOTE" updatefields="true"></docpart>
   </docparts>
</doc> 

That’s it! We appreciate your feedback! Please share your thoughts by sending an email to support@mscrm-addons.com.

Was this helpful?

Yes  No
Related Articles
  • Sample Templates 
  • Dynamic document Header & Footer selection via the DocumentsCorePack Dialog
  • Azure Blob Storage: Setting Recommendations 
  • Migrating One-Click-Actions Using the Data Migration Tool 
  • Force Service to be the only document-generating service
  • The DocumentsCorePack Dialog
Leave A Comment Cancel reply

You must be logged in to post a comment.

Latest Articles
  • Sample Templates 
  • Step-by-Step: How to create an account sales report template
  • Step-by-Step: How to create a NDA-contract template 
  • Step-by-Step: How to create a work order template
  • Step-by-Step: How to create a quote template 
Popular Articles
  • DocumentsCorePack Template Designer – Getting Started
  • Step-by-Step: How to configure a One-Click-Action
  • Where do I find the Unique Organization name in Microsoft Dynamics 365?
  • mscrm-addons.com Application Access for Dynamics 365 (App Access) – DocumentsCorePack
  • DocumentsCorePack Online Service Configuration
Top Rated Articles
  • “Undefined”-labels in Chrome and Edge 114 and higher
  • IMPORTANT information for Dynamics 365 online customers using DocumentsCorePack and/or AttachmentExtractor
  • How to activate the DocumentsCorePack connector for PowerApps & Microsoft Flow
  • Step-by-Step: How to configure a One-Click-Action
  • How licenses are counted
Categories
  • *News and General Infos* 52
  • Webinars 37
  • Template Designer(DCP 192
  • DocumentsCorePack(DCP 204
  • TelephoneIntegration (TI 65
  • AttachmentExtractor (AE 64
  • PowerSearch (PS 48
  • ActivityTools (AT 59
  • SmartBar (SB 53
  • GroupCalendar (GC 46
Our Vision

“We see it as our purpose to provide products that simplify and speed up our customers’ Microsoft Dynamics 365 experience.”

Knowledgebase
LogIn
mscrm-addons.com
  • Products
  • Online Shop
  • Downloads
  • My Account
About Us
  • About Us
  • Case Studies
  • Newsletter
  • Partner Program
  • Contact
Support
  • Support
  • Terms & Conditions
  • Documentation
  • Webinars
  • Legal Documents
  • Impressum
  • © 2022 www.mscrm-addons.com. All Rights Reserved.