Published by Barry Francis on the 09 of November 2018.

Content

Rules/Limitations

Navigation

Enable Developer Tab

Creating a Word Template

Uploading a Word Template

Document Template Security

Workflow using Templates

Microsoft Flow Converting to PDF

Microsoft Dynamics 365 Word Templates

Before Microsoft Dynamics Word templates was introduced, we had to create our own documents through mail merge, custom development or manual capture.

Word and Excel templates have given us the ability to upload templates that can be used to generate a document with dynamic data inserted from Dynamics 365 data sources. This then allows any user the opportunity to create their own custom designed document templates and use them in most scenarios.

Rules/Limitations

There are a few rules/limitations that you need to be aware of before you consider creating your own Word Templates, namely:

  • There is a limit of 100 associated records that can be returned for each relationship.
  • The report cannot filter/sort the associated data that is returned
  • If any of the attribute values are empty, the placeholder reserves its location, meaning if no value is passed through, the attribute location will remain blank.
  • To list records as seen in a view, you will need to use an Excel template.
  • You will not be able export a template from a Sandbox instance and import it into another Dynamic 365 instance. The only possible way to do this is to ensure that the most recent Word Template that was uploaded to Sandbox is uploaded to Production.
  • Inserting a content control other than Picture or Plain Text can cause Word to freeze. To prevent this:
    1. Only add fields as Plain Text or Picture
    2. Do not make any textual changes to the added content control

Reference (https://docs.microsoft.com/en-us/dynamics365/customer-engagement/admin/using-word-templates-dynamics-365)

  • There is no functionality that allows for an update of an existing document. Any updated document will need to be manually uploaded and the previous document deactivated or deleted.

To begin creating a Microsoft Word Template, navigate to Settings > Templates > Document Templates.

Then click on the New button to begin creating a Dynamics 365 Word Template.

Enable Developer Tab

This tab is not enabled by default and must be enabled before you can begin creating new word templates.

To enable this tab, select File > Options > Customize Ribbon > Main Tab within Microsoft Word and then tick the Developer tab.

Creating a Word Template

When ready, click on the New button and then the Select Entity button.

There you will be required to select all the entities you wish to include against the primary entity you’ve selected.

Each associated entity in the relationship list will allow for additional mappings to be included.

NOTE

  • Try not selecting all the entities in the lists as the template will take an exceptional amount of time to be downloaded.
  • From the time on writing this, I experienced some issues with the downloading of the templates from Internet Explorer, sometimes the browser would stall and cause my CPU to run at 100%. I found that using Chrome or Firefox was much quicker.
  • If you create a Word Template from the settings module, the document template will be considered a system template and will be visible and accessible by all who have the correct security permissions. If you create a new word template from an entity record, it will be created as a personal document template! This document will not be visible from within the setting module, but via advanced find under Personal Document Templates.

A blank word document will be opened.

Click on the Developer tab and then click on the XML Mapping Pane button under it.

On the right XML Mapping pane, click on the drop down list and choose the XML part labelled: urn:Microsoft-crm/document-template/[ENTITY]

This will load all the attributes that fall under the primary entity you selected.

The 1:N relationship will show under the main entity:

To begin, build a template that you can simply add Dynamics 365 data fields to:

Then, using the XML Pane, right click on any of the fields and choose to input them as plain text.

This will serve as a mapping for entity record you run this template from.

Should you wish to create a table of associated records:

  • Highlight the initial row you wish to have repeated
  • Right click the associated record and choose to insert content control that is Repeating

  • Add the mappings thereafter as you did for the rest of the template (Plain Text Control).