The Multipart feature within a One-Click-Action (OCA) can configure a document package consisting of multiple elements like templates, files from SharePoint, or files attached to notes. However, Multiparts can also be constructed outside of an OCA by building the necessary XML itself. This custom XML can be built and used in custom apps, JavaScript, or even Power Automate. This is useful for scenarios that require integration with Power Automate or custom applications.
The article below serves as a guide and reference to creating custom XML for Multiparts.
Multipart XML structure
Multipart documents are based on structured XML using the <doc>, <docparts>, and <docpart> tags. The typical layout is depicted below:
<doc>
<docparts ... >
<docpart template="TEMPLATE" entity="ENTITY" entityid="ENTITYID"></docpart>
<docpart ... ></docpart>
<docpart ... ></docpart>
</docparts>
</doc>
In the XML, there can be only one set of <doc> tags and one set of <docparts> tags, but there can be multiple <docpart> tags, with each one representing a particular template, SharePoint file, or Note.
Both the <docparts> and <docpart> tags can contain multiple parameters. These parameters are detailed below.
Parameters for <docparts>
converttopdf
A true or false value. If this value is set to true, the generated document will be converted to a PDF. This parameter is not required if the document does not need to be converted to a PDF.
converttopdf="true"
savetosharepoint
A true or false value. If this value is set to true, the generated document will be saved to SharePoint. This location can be further specified using the stsentitytype and stsentityid parameters. This parameter is not required if the document does not need to be saved to SharePoint.
savetosharepoint="true"
stsentitytype
The logical name of an entity. This parameter, in combination with stsentityid, defines the SharePoint location where the generated document will be saved.
stsentitytype="account"
stsentityid
The ID of a record. This parameter, in combination with stsentitytype, defines the SharePoint location where the generated document will be saved.
stsentityid="ENTITYID"
Parameters for <docpart>
template
The GUID of the specified template. This parameter must be defined if a template is included as part of the Multipart.
<docpart template="TEMPLATEGUID"></docpart>
entity
The logical name of the entity the Multipart is based on. If, for example, the Multipart document is being created for the Account entity, then this parameter should be set to “account.”
entity="account"
entityid
The ID of the record the Multipart is based on.
entityid="ENTITYID"
displayname
The name of the docpart to be displayed in the Dialog.
displayname="CoverPage"
SharepointUrl
The URL of the file on SharePoint you want to include in your multipart. This parameter is required if the document to include is stored on SharePoint.
SharePointUrl = "https://crmXXXXXX.sharepoint.com"
Note: This parameter effectively replaces the template parameter when used in a docpart. This parameter should not be used in tandem with the entity or entityid parameters.
Note
The ID of a note within Dataverse.
Note = "NOTEID"
Note: This parameter effectively replaces the template parameter when used in a docpart. This parameter should not be used in tandem with the entity or entityid parameters.
updatefields
A true or false value. If this parameter is set to true, all standard Word fields across all templates will be updated (e.g. Tables of contents, page numbers).
This parameter should be included in the final template docpart tag of your Multipart XML in order to properly update the fields of all templates. This parameter does not work if it is applied to a docpart that is not a template (e.g. a Note or SharePoint URL).
updatefields = "true"
concatinatetype
concatinatetype="Doc/Content, Formatting, Linking, SectionBreak, Page Numbering, xml"
A parameter defined by a list of values that determines how the generated document should be concatenated. The list is structured in XML as follows:
Each comma separated value in the above list (aside from “xml,” which is always included at the end of the list) represents a unique concatenation setting. These settings are detailed below.
Doc/Content
Determines if either the document (Doc) or the contents of the document (Content) should be concatenated.
If this setting is omitted, the Doc parameter is used by default.
Parameter | Description |
Doc | If this setting is used, the document will be appended to the previous document. |
Content | If this setting is used, only the contents of the document will be appended to the previous document. Headers, footers, and section breaks within the document will be ignored. |
XML example:
concatinatetype="Content, xml"
Formatting
Determines if the formatting of the document will be retained or if it should adopt the formatting of the previous document.
If this setting is omitted, the KeepSourceFormatting parameter is used by default.
Parameter | Description |
KeepSourceFormatting | The formatting of the document will be retained. For example, if the document uses a different font for a certain heading, that difference will be kept. |
UseDestStyle | The formatting of the previous document will be applied to this document. For example, if the document uses a different font for a particular heading, that font will be ignored and the same font in the previous document will be used instead. |
XML example:
concatinatetype="UseDestStyle, xml"
Linking
Determines how the sections in this document and the previous document are “linked.” If sections are “linked,” that means that the header/footer from the previous section will carry over to the next section.
If this setting is omitted, the AutoLink parameter is used by default.
Parameter | Description |
AutoLink | If this section has no or an empty header/footer, then it will be linked to the section document. Otherwise, it will not be linked. |
Link | The first section of this document will be linked. |
LinkAll | All sections of this document will be linked. |
Unlink | The first section of this document will be unlinked. |
XML example:
concatinatetype="Unlink, xml"
SectionBreak
Determines which type of section break is used between this document and the previous document in the Multipart.
If this setting is omitted, the KeepSectionBreak parameter is used by default.
Parameter | Description |
KeepSectionBreak | The type of the SectionBreak between the two documents is defined by the type of the first section of this document. By default, the first section’s break type is a “Next Page” break. Note: If this document and the previous document are sized differently, a “Next Page” break will be created between them. |
NewPage | A “Next Page” break will be created between the two documents. |
Continuous | A “Continuous” break will be created between the two documents. Note: If this document and the previous document are sized differently, a “Next Page” break will be created between them. |
XML example:
concatinatetype="Continuous, xml"
Page Numbering
Determines if the page numbering of the document will follow the previous document’s numbering or not.
If this setting is omitted, the ContinuePageNumbering parameter is used by default.
Parameter | Description |
ContinuePageNumbering | The page numbering of the document will continue where the previous document left off. |
RestartPageNumbering | The page numbering of the document will restart from 1. |
XML Example
concatinatetype="RestartPageNumbering, xml"
Walking through an example
We would like to create a document package for a new customer. This document package should consist of three documents: a welcome letter, a special welcome discount, and an NDA. The documents within the package should be concatenated with continuous page numbering, and each one should start on a new page. The header for each document should be taken from the first document in the package. Additionally, the generated package should be converted to a PDF and be saved to SharePoint.
Creating a Flow
We’ll create our document package by building the XML in a Flow in Power Automate. Our Flow will be centered on appending information to a string variable.
Our first addition to our XML will include the opening <doc> tag followed by our <docparts> tag. Within the <docparts> tag, we will add the savetosharepoint, stsentitytype, and stsentityid parameters to save the final document package to SharePoint. The converttopdf parameter is needed to convert the package to a PDF.
The next addition will be our first <docpart> tag, which will include information on the first template of our document package. The template parameter will contain the GUID of the template to be executed, and the entity and entityid parameters will contain the information on the record to be executed against.
The second docpart will contain information on the next template, with the addition of the concatinatetype parameter list. This list will dictate how the document package will be concatenated, with each of the listed items influencing the process (see “concatinatetype” above).
Our third docpart will similarly contain the template and concatenation information. Since this is our last docpart, we need to include the updatefields parameter to update any Word fields included in this or any of the preceding templates. At the very end, we will close our <docparts> and <doc> tags, signaling the end of our XML.
For the final step of our Flow, we will add an action from our DocumentsCorePack Connector that will construct the document package based on the variable that holds our XML.
The result
Running this Flow will generate a document package as shown below.

Sample XML
Below is the XML used in the Flow with placeholders inserted. Feel free to repurpose it for your own Flows!
<doc>
<docparts savetosharepoint="true" stsentitytype="ENTITYNAME" stsentityid="ENTITYID" converttopdf="true">
<docpart template="TEMPLATEID" entity="ENTITYNAME" entityid="ENTITYID"/>
<docpart concatinatetype="LinkAll, NewPage, xml" template="TEMPLATEID" entity="ENTITYNAME" entityid="ENTITYID"/>
<docpart concatinatetype="LinkAll, NewPage, xml" template="TEMPLATEID" entity="ENTITYNAME" entityid="ENTITYID" updatefields="true"/>
</docparts>
</doc>
That’s it! We appreciate your feedback! Please share your thoughts by sending an email to support@mscrm-addons.com.