mscrm-addons.com logo displayed here.mscrm-addons.com logo displayed here.
  • Release History
  • Documentation
  • Back to www.mscrm-addons.com
  • Release History
  • Documentation
  • Back to www.mscrm-addons.com
home/Knowledge Base/DocumentsCorePack(DCP)/Building Custom XML for Multipart documents

Building Custom XML for Multipart documents

412 views 0 Updated on June 16, 2025

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. 

ParameterDescription
DocIf this setting is used, the document will be appended to the previous document. 
ContentIf 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. 

ParameterDescription
KeepSourceFormattingThe 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. 
UseDestStyleThe 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. 

ParameterDescription
AutoLinkIf this section has no or an empty header/footer, then it will be linked to the section document.  Otherwise, it will not be linked. 
LinkThe 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. 

ParameterDescription
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. 

ParameterDescription
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" 

Defining a document filename

In DocumentsCorePack, there are several ways to define the filename when generating a document from a Multipart XML.

Document name from the template (default behavior)

The document name is taken from and defined within the first template. If the first DocPart doesn’t contain a defined document name, the next one with a defined name will be used. Thus, the first found document name in the sequence is applied.

Controlled selection with filenameposition

In the XML header, you can set the attribute filenameposition (as a string). In the below example, this explicitly sets the document name from the DocPart at position 2 – regardless of any previously defined document name.

filenameposition="2"

Fixed filename with filename=”…”

If the XML header contains the filename attribute, the specified name will be used. It overrides any other settings or values defined in the templates. The below example shows how to define “MyDocument.pdf” as the filename.

filename="MyDocument.pdf"

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. 

Initializing our XML variable
Figure 1: Initializing our XML 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. 

Figure 2: Appending the <docparts> tag and its parameters

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. 

Appending our first docpart
Figure 3: Appending our first docpart

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). 

Appending our second docpart.
Figure 4: Appending our second docpart

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. 

Appending our third and final docpart
Figure 5: Appending our third and final docpart

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. 

Passing in our XML variable to the action to create the document package
Figure 6: Passing in our XML variable to the action to create the document package

The result

Running this Flow will generate a document package as shown below. 

The first page of our document package, a welcome letter
Figure 7a: The first page of our document package, a welcome letter
Figure 7b: The last page of our document package, an NDA. The pictured header originates from the first template.

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.

Tags:xmlOCAone click actioncustomMultipartone-click-action

Was this helpful?

Yes  No
Related Articles
  • Deploying DocumentsCorePack: Setup, Automation, and Real Business Impact in Dynamics365
  • Introducing the DocumentsCorePack Template Designer Office Add-In (Beta)
  • 3 Ways DocumentsCorePack Transforms Proposal, Quote, and Contract Creation
  • DeepSign for DocumentsCorePack 
  • Generate and send a document for e-signing using DeepSign
  • How to prepare a document for DeepSign
Latest Articles
  • What Happens After You Deploy AttachmentExtractor: Storage & Cost Savings in Dynamics 365
  • Deploying DocumentsCorePack: Setup, Automation, and Real Business Impact in Dynamics365
  • Introducing the DocumentsCorePack Template Designer Office Add-In (Beta)
  • How to Eliminate Excess Storage Costs in Microsoft Dynamics 365 Without Losing Access to Emails and Attachments
  • 3 Ways DocumentsCorePack Transforms Proposal, Quote, and Contract Creation
Popular Articles
  • DocumentsCorePack Template Designer – Getting Started
  • Step-by-Step: How to configure a One-Click-Action
  • Application Access for Dynamics 365
  • How to find your environment’s unique name in Microsoft Dynamics 365
  • How licenses are counted
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
  • How to insert Condition Fields in DocumentsCorePack Templates designer
  • How licenses are counted
Categories
  • *News and General Infos* 64
  • Webinars 45
  • Template Designer(DCP 196
  • DocumentsCorePack(DCP 258
  • TelephoneIntegration (TI 65
  • AttachmentExtractor (AE 75
  • PowerSearch (PS 50
  • ActivityTools (AT 61
  • SmartBar (SB 54
  • GroupCalendar (GC 47
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.