Word Templates in Microsoft Dynamics CRM

Microsoft Dynamics CRM 2016 was released in January of this year. With it, Microsoft has released template functionality for Microsoft Word and Excel that allows you to extract data from CRM using a standard document.  Word 2013 or 2016 is required in order to use this feature and is a step up from merging with previous versions of CRM.

If you have a requirement to send or print the same type of documents multiple times at random time intervals, this feature will save valuable time by by allowing you to set up a “base” document for exporting data from within your CRM system and allow you to edit, if required, outside of your CRM system.

The basic steps for setting up your Word template are outlined below. Note that you are required to have System Administrator security level permissions in order to create these templates.

In this example I use a basic letter template, but you can set up your template in any way you want, within the limits of Word itself.

Steps: Using Word Templates with Dynamics CRM

1) Navigate to Settings | Templates

image1
View Full Size

2) In the Templates area, click on Document Templates

image2
View Full Size

After clicking on Document Templates, you will see a list of existing templates with their Name, Status and Modified on Date and who modified it.  You can choose to modify a template here but for the purposes of this blog, we will create new.

3) Click on the +New button on top left.

image3
View Full Size

A dialog box to select the template type and entity are presented.

4) Click on Word Template

image4 

5) Click on Word Template and at Filter by entity, using the drop down arrow select Contact.

image5

6) When ready, click on the Select Entity button.

After clicking on Select Entity, you will see a dialog that displays the entity relationships.  There are different types of relationships to other entities to consider.  It’s important to understand these relationships before moving on with the download of a template for editing.

1:N This is a one-to-many relationship. This means that one contact record will have many records connected to the related entity.  Example: One Contact has many Activities

image6

N:1 This is a many-to-one relationship. This means that many contacts have one record in the related entity. Example: Many contacts have one Business Unit

N:N This is a many-to-many relationship. This means that many contact records have many records in the related entity.  Example: Many Contacts have Many Contracts

Your relationship entities selection will depend on the type of information you need to have in your template.  If you need all the Contact information, plus the information from the Account in which the Contact is connected to, you will select the N:1 Relationship for Account with the Schema Name of contact_customer_accounts.  Note: The schema is the organization, or structure of the entity. It’s the same database principle used in Microsoft SQL Server.

7) To select the relationship, simply click once on the name. For our example, we will click the N:1 relationship Account.  Then Click on Download Template.

You will get the dialog box below. You have a choice here to Save it and then open it later or simply Open, make the change and then save it.

image7

8) Click Open and the document template will open in Word.

In the next steps, you will specify the fields you want in your template based on the entity you have selected for population.  First you need to enable the Developer Tab in Word.  To do so, follow the instructions here to enable it.

9) To start inserting fields into your template, you will need to set up XML Mapping.

  1. Click on the Developers tab
  2. Click on XML Mapping Pane
  3. When the XML Mapping Pane comes up, select urn:microsoft-crm/document-template/<entity name>/
image8

10) To begin inserting the field controls, expand the Contact entity be clicking on the arrow at the left.

image9

It will then expand and you will see the list of field controls available to you for insertion.  We will start with the Contact fullname.

11) Scroll down Click on fullname

  1. d) Right-click fullname to bring up its local context window.
  2. e) Click on Insert Content Control
  3. f) Select Plain Text

[alert type=”notice”]Note of caution here; at the time of this writing there is a known issue whereas if you try to insert a control other than a Picture or Plain Text, Word may freeze.[/alert]

 

image10

Continue to insert your controls until you have the dynamic content you need and the final document template you want to create.  I have done a simple letter with controls for:

  1. fullname,
  2. account name,
  3. address fields, and
  4. firstname of the recipient.

Note that because the account name is in the N:1 relationship that we selected in step 7, you will need to get that field from XML mapping on customer_contact_accounts.

image11

12) Save your template (any name will do)

13) Now in CRM you will navigate back to CRM -> Settings | Templates

14) Click Upload Template

image12

The Upload Template dialog box will appear.  You have two choices here: you can click on browse to choose the file or simply drag the saved template file from Windows into the blue box with the cloud.

15) Browse and select your file or drag the template file.  Click Upload.

image13

16) Once the document template is loaded, you will be prompted to enter the properties and Name of the template as shown below.

I’ll simply name it Contact Letter.

image14

17) Save the record.

Your template is now in CRM and it will auto activate, but you aren’t finished yet. You will need to specify who can actually use this template. You will do this by enabling the security controls.

18) In the same window, click on Enable Security Roles

image15

The Enable Security Roles dialog appears and will give you a choise to Enable for Everyone (all system users), or to select which security roles to enable.  I’ll choose CSR Manager.

19)  Select the security role and Click the OK button.

image16

20)  Finally, to use the template that you created: navigate to the Contact record you wish to send the letter to.

  1. Click the ellipsis (…) on the navigation bar.
  2. Select Word Template.
  3. Select your new template from the list.
image17

The finished product is a basic example of a letter template.  In your template, regardless of content, ensure that you include proper branding. Happy Templating!

image18

 

 

Dynamics 365 CRM How-To eGuide

41 pages of step-by-step instructions for 6 different key tasks in Dynamics 365 CRM apps. Includes interactions with Power Apps and Power Automate!

Get eGuide

Dynamics 365 CRM How-To eGuide

Get eGuide