Edit

Share via


Use Word templates to create standardized documents

After you create and import Office Word templates into customer engagement apps (Dynamics 365 Sales, Dynamics 365 Customer Service, Dynamics 365 Field Service, Dynamics 365 Marketing, and Dynamics 365 Project Service Automation), users select one button to generate standardized documents automatically populated with data. This feature has some special considerations you need to know to successfully create Word templates.

Warning

There's a known issue when creating templates in Word. It's important to review and follow the guidance in the Avoid a known issue when creating templates section of this article to prevent interactions that could potentially destabilize Word.

Supported versions of Word

Area Word Version
Creating a Word template 2013, 2016
Using a Word document generated in customer engagement apps 2010, 2013, 2016

Note

Macro-enabled Word documents (.docm) are not supported.

Follow the steps in this article to successfully create and use Word templates in customer engagement apps.

Step 1: Create a Word template

Where you can create a template

There are two places in customer engagement apps where you can create a Word template:

  • From Power Platform admin center.

    Access requires sufficient permissions, such as System Administrator or System Customizer role. To check your security role, see View your user profile. If you don't have the correct permissions, contact your system administrator.

    1. Sign in to the Power Platform admin center.
    2. In the navigation pane, select Manage.
    3. In the Manage pane, select Environments and choose an environment.
    1. On the Environments page, go to the command bar and select Settings.
    2. Expand Templates, then select Document templates.
    3. In Microsoft Dynamics 365, go to the command bar and select New to open the Create template from CRM data dialog box.
  • From a list of records. For example:

    1. Sign in to the Sales Hub app.
    2. In the navigation pane, select Opportunities.
    3. From the grid view selector in the command bar, select My Open Opportunities to display a list of records.
    4. In the list, select Word Templates, then select Create Word Template to open the Create template from CRM data dialog box.

    Create a Word template from an entity.

Tip

To delete personal document templates, follow these steps:

  1. Select Advanced Find (Screen shot of Advanced Find button.).
  2. For Look for, select Personal Document Templates.
  3. Select Results (!).
  4. Choose the personal document template to delete and then select Delete (Delete button.).

To update templates, delete the template and then upload an updated version.

In the Create template from CRM data dialog box:

  1. Select Word Template.
  2. Choose an entity to filter with.
  3. Select Select Entity to open the Select Entity dialog box.

Choose Word Template and select entity.

In the Select Entity dialog box you configure the entity relationships.

Select entities for the Word template.

What are 1:N, N:1, and N:N relationships?

This screen requires an understanding of your customer engagement apps data structure. Your admin or customizer can provide information about entity relationships. For admin content, see: Entity relationships overview.

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 data to the Word template.

Note

To ensure documents download quickly, only return up to 100 related records for each relationship. For example, if you export a template for an account, and want to include a list of its contacts, the document will return at most 100 of the account's contacts.

Download the template

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

Important

You can only use a document template in the environment where you downloaded it. Environment-to-environment migration for Word or Excel templates isn't supported.

Step 2: Enable the Developer tab

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

The Word template when first opened.

To see and add customer engagement apps 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. Select OK.

    Developer now appears in the Word ribbon.

    Developer tool on Word Ribbon.

Avoid a known issue when creating templates

There's a known issue with customer engagement apps' apps-generated Word templates and Office Word. Follow the guidance in this section to prevent issues with control fields before going to step three where you add XML content control fields to the Word template.

Warning

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.

Only add fields as Plain Text or Picture

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

Insert the field as Plain Text.

Do not make any textual changes to the added content control

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.

Turn 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. Select OK.

Step 3: Define the template

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

  1. In your Word template, select Developer > XML Mapping Pane to select the default XML schema.

    Select XML Mapping Pane in the Word ribbon.

    The default XML Mapping schema.

  2. Select the XML schema. It will begin with "urn:microsoft-crm/document-template/".

    Select the XML schema.

    Important

    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, Avoid a known issue when creating templates.

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

    Insert the field as Plain Text.

    The entity field is added to the Word template.

    The 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 customer engagement apps to create a document, the table populates with multiple rows of data.

    When the template has the fields and formatting you want, save it and upload it into customer engagement apps.

Step 4: Upload the Word template back into customer engagement apps

When you have your Word template built the way you want, save it so you can upload it into customer engagement apps.

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.

Administrators can use the Settings page to upload the Word template into customer engagement apps. A template uploaded in Settings is available to all users in your organization.

For admins: Upload the Word template into customer engagement apps

  1. Go to Settings > Templates > Document Templates.

  2. Select Upload Template.

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

    Upload Template dialog box.

  4. Select Upload.

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

For non-admins or admins wanting to create a personal template: Upload the Word template into customer engagement apps

  1. 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, select More () > Word Templates > Create Word Template.

  3. Select Word Template > Upload.

    Select Upload to bring the template into customer engagement apps.

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

  5. Select Upload.

Step 5: Generate a document from the Word template

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. Select 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 customer engagement apps to see the template. Either refresh your browser or close and reopen customer engagement apps.

    After you select your Word template, customer engagement apps create a Word document from the record you selected.

Try out the sample Word templates

There are five Word templates included with customer engagement apps.

These templates are included with customer engagement apps.

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. Select More () > Word Templates, and then under Word Templates select the sample template.

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

Note

You can review but not edit templates that are included in customer engagement apps.

Additional considerations

Use Security Roles to control access to templates

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. Select 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. Select the circles to adjust the level of access.

    Adjust access using the security role.

Lists in created documents are not in the same order as records

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

Issue with right-to-left languages

Content in right-to-left (RTL) languages may have some formatting issues in the Word file after the document is created.

See also

Analyze your data with Excel templates

Troubleshooting Word templates