Using Word templates in Dynamics 365

Dynamics CRM 2016
 

Updated: November 1, 2016

Applies To: Dynamics 365 (online), Dynamics 365 (on-premises), Dynamics CRM Online, Dynamics CRM 2016

This feature was introduced in CRM Online 2016 Update and CRM 2016 (on-premises).

Interested in getting this feature? Find your Dynamics 365 administrator or support person.

After you create and import Microsoft Office Word templates into Microsoft Dynamics 365, with one click users can generate standardized documents automatically populated with Dynamics 365 data. This feature has some special considerations you should know about to successfully create Word templates.


System_CAPS_warningWarning

There is a known issue when creating templates in Word. This topic contains information on how to prevent interactions that could potentially destabilize Word. See: Important! A known issue and how to avoid it


The following are the supported versions of Word.

Area

Word Version

Creating a Word template

2013, 2016

Using a Word document generated in Dynamics 365

2010, 2013, 2016



Follow the steps in this topic to successfully create and use Word templates in Dynamics 365.

There are three places in Dynamics 365 where you can create a Word template:

  • From the Settings page. Go to Settings > Templates > Document Templates > New(New or Add button). You’ll need sufficient permissions to access to the Settings page, such as System Administrator or System Customizer.

  • From a record. Open a record such as an account in Sales. Go to Sales > Client_Accounts > My Active Accounts. Click an account to open it, and then click More () > Word Templates > Create Word Template. Templates created here are personal and available only to the user creating the template.

  • From a list of records. For example, go to Sales > Client_Accounts > My Active Accounts. Select a single account, and then click More () > Word Templates > Create Word Template.

    Create a Word template from a Dynamics 365 entity

System_CAPS_tipTip

To delete personal document templates, do the following:

  1. Click Advanced Find (Screen shot of Advanced Find button).

  2. For Look for, select Personal Document Templates.

  3. Click Results (!).

  4. Select the personal document template to delete and then click Delete (Delete button).

After clicking Create Word Template, select an entity to filter with, and then click Word Template > Select Entity.

Choose Word Template and select entity

The relationship selection page appears.

Select entities for the Word template

This screen requires an understanding of your Dynamics 365 data structure. Your Dynamics 365 administrator or customizer can provide information about entity relationships. For admin content, see: Create and edit entity relationships.

Here are some example relationships for the Account entity.

Relationship

Description

A 1:N entity relationship

An account can have multiple contacts.

An N:1 entity relationship

A lead, account, or contact can have multiple accounts.

An N:N entity relationship

An account can have multiple marketing lists.

A marketing list can have multiple accounts.

The relationships you select on this screen determine what entities and fields are available later when you define the Word template. Only select relationships you need to add Dynamics 365 data to the Word template.

System_CAPS_noteNote

To ensure documents download in a timely matter, there is an upper limit of 100 for the number of related records returned for each relationship. For example, if you’re exporting a template for an account, and you want to include a list of its contacts, the document will return at most 100 of the account’s contacts.

Click Download Template on the Select Entity page to create a Word file on your local computer with the exported entity included as XML data.

Open the Word template file. At this point, the document appears to be blank.

The Word template when first opened

To see and add Dynamics 365 XML data, you need to enable the Word Developer tab.

  1. Go to File > Options > Customize Ribbon, and then enable Developer.

    Add Developer to the Word Ribbon

  2. Click OK.

Developer now appears in the Word ribbon.

Developer tool on Word Ribbon

There’s a known issue with Dynamics 365-generated Word templates and Microsoft Office Word. In the next section, you’ll be adding XML content control fields to the Word template.

System_CAPS_warningWarning

A few things can cause Word to freeze, requiring you to use Task Manager to stop Word:

  • You insert a content control other than Picture or Plain Text.

  • You make a textual change, such as changing the capitalization or adding text, to a content control. These changes can occur through AutoCorrect as well as user edits. By default, Microsoft Word AutoCorrect capitalizes sentences. When you add a content control field, Word sees it as a new sentence and will capitalize it when focus shifts away from the field.

To prevent issues with control fields, do the following:

  1. You use the XML Mapping Pane to add Dynamics 365 entity fields to your Word template. Be sure to only add fields as Plain Text or Picture.

    Insert the Dynamics 365 field as Plain Text

  1. You can make formatting changes to content control fields, such as bolding the text, but no other textual changes, including capitalization changes.

    Don't change any text in these fields!

If you experience Word freezing or performance degradation, try turning off AutoCorrect.

  1. With the template file open in Word, go to File > Options > Proofing > AutoCorrect Options.

    In Word, select Proofing > AutoCorrection Options

  2. Deselect Capitalize first letter of sentences and Automatically use suggestions from the spelling checker.

    Deselect the AutoCorrect settings

  3. Deselect Hyphens (--) with dash (-) on the AutoFormat and AutoFormat as You Type tabs.

  4. Click OK.

If you followed the above recommendations, you’re ready to define the Word template.

Use the XML Mapping Pane to define the Word template with Dynamics 365 entity fields.

  1. In your Word template, click Developer > XML Mapping Pane.

    Select XML Mapping Pane in the Word ribbon

    The default XML schema is selected.

    The default XML Mapping schema

  2. Select the Dynamics 365 XML schema. It will begin with “urn:microsoft-crm/document-template/”.

    Select the Dynamics 365 XML schema

    System_CAPS_importantImportant

    If you have frequent accidental edits that cause Word to freeze or have performance degradation, be sure to turn off the AutoCorrect options according to the section: “A known issue and how to avoid it”.

  3. Expand the Dynamics 365 entity, right-click the entity field, and then click Insert Content Control > Plain Text.

    Insert the Dynamics 365 field as Plain Text

The Dynamics 365 entity field is added to the Word template.

The Dynamics 365 field is inserted into the Word template

Add additional entity fields, add descriptive labels and text, and format the document.

A completed template might look like this:

Sample Word template

Some content control fields you entered likely have multiple lines of data. For example, accounts have more than one contact. To include all the data in your Word template, set the content control field to repeat.

Set content control fields to repeat

  1. Put fields with repeating data in a table row.

  2. Select the entire table row in the template.

    Create a table and add content control fields

  3. In the XML Mapping Pane, right-click the relationship containing the content control fields, and then click Repeating.

    Set the table row to repeating

When you use the Word template in Dynamics 365 to create a document, the table will populate with multiple rows of data.

When the template has the fields and formatting you want, save it and upload it into Dynamics 365.

‘When you have your Word template built the way you want, save it so you can upload it into Dynamics 365.

Access to the newly created Word template depends on how you uploaded it and to the access granted to the security role. Be sure to check out Use Security Roles to control access to templates.

Dynamics 365 administrators can use the Settings page to upload the Word template into Dynamics 365. A template uploaded in Settings is available to all users in your Dynamics 365 organization.

  1. In Dynamics 365, go to Settings > Templates > Document Templates.

  2. Click Upload Template.

  3. Drag the Word file in the dialog box or browse to the file.

    Upload Template dialog box

  4. Click Upload.

Non-admin users can upload a template for their own use from a list of records.

  1. In Dynamics 365, open a page with a list of records, for example, the list of customer accounts in Sales.

  2. Select a single item such as an account, click More () > Word Templates > Create Word Template.

  3. Click Word Template > Upload.

    Click Upload to bring the template into Dynamics 365

  4. Drag the Word file in the dialog box or browse to the file.

  5. Click Upload.

To use the Word template you’ve created, do the following:

  1. Open a record with information you want to create a document. For example, open a customer account record in Sales.

  2. Click More () > Word Templates, and then under Word Templates select the template you created.

    If the template you created is not visible, there are two possibilities:

    1. Only templates built for the selected record type (entity) will be displayed. For example, if you open an opportunity record, you will not see a template you created with the Account entity.

    2. You need to refresh Dynamics 365 to see the template. Either refresh your browser or close and reopen Dynamics 365.

After you select your Word template, Dynamics 365 creates a Word document from the record you selected.

There are five Word templates included with Microsoft Dynamics 365.

These templates are included with Dynamics 365

The sample Word templates were created with a particular record type (entity). You’ll only be able to apply the template to records of the same record type.

Name

Entity

Opportunity Summary

Opportunity (Sales area)

Campaign Summary

Campaign (Marketing area)

Case Summary

Case (Service area)

Invoice

Invoice (Sales area)

Account Summary

Client_Account (Sales, Service, and Marketing areas)

To apply a sample Word template

  1. Open a record with information with the entity type that matches the sample template. For example, open a customer account record in Sales to apply the Account Summary template.

  2. Click More () > Word Templates, and then under Word Templates select the sample template.

Open the newly-created Word template and give it a look.

System_CAPS_noteNote

You can review but not edit templates that are included in Microsoft Dynamics 365.

Dynamics 365 administrators can control access to Word templates with some granularity. For example, you can give salespeople Read but not Write access to a Word template.

  1. In Dynamics 365, click Settings > Security > Security Roles.

  2. Select a role, and then click the Business Management tab.

  3. Select Document Template to set access for templates available to the entire organization. Select Personal Document Template for templates shared to individual users.

  4. Click the circles to adjust the level of access.

Adjust access using the security role

Lists of records created from a custom template may not appear in the same order in Word documents as the order in Dynamics 365. Records are listed in the order of the time and date they were created.

Show: