A new feature introduced in Dynamics CRM 2016 Online and CRM 2016 on premise is the Word Templates. In this blog, we’ll use this new feature to generate a document with data from a CRM instance.
For creating a template, you would need MS Word to be in version 2013 or 2016. There are 3 ways to create a Word template.
Considering that you would have the system admin access rights on the CRM instance, the first method to create a Word Template is from the Settings page. Go to Settings > Templates > Document Templates > New.
The second method is creating personal templates. These templates are only available to the user creating the template.
For creating a personal Word template, open an existing record. For example, open an account record and then click (…) > Word Templates > Create Word Template.
The third way to create a word template is from a list of records. For example, go to Sales > Accounts. From the list of records, select a single account, and then click (…) > Word Templates > Create Word Template.
Method 3 step by step Process
Let’s look into creating a template with the last method. This would again be a Personal Template.
Go to Sales > Account. From the record list, select an account record and click on the three dots (…).
Then, select Word Templates > Create Word Template.
We’ll look into Excel templates in the next blog. For now, on the popup: 1) select the Word Template, 2) Select the entity (Account would be filtered by default), and 3) Click on “Select Entity”.
On the new pop up, we need to select the related entities from which we would input data onto the template.
Let’s select Contact, Lead, Account and then Click on “Download Template”
This would prompt to save the template on the local machine. Select a location and give the document an appropriate name. For example, “Account Summary <date>”.
Open this Word Template. The document would be blank.
To add CRM XML data, you need to enable the Word Developer tab. Go to File > Options > Customize Ribbon, and then enable Developer.
There are few known issues with the Word Template for Dynamics CRM feature, and there are few known resolutions. Let’s set them before we start with the template.
In the File > Options, go to “Proofing” and select “Autocorrect Options”.
Deselect “Capitalize first letter of sentences” and “Automatically use suggestions from the spelling checker”
In the Auto Format Tab deselect “Hyphens (–) and dash (—)”
On the “AutoFormat As you Type” Tab deselect “Hyphens (–) and dash (—)” and Click OK.
Now you would see a new “Developer” tab on the word document.
Select the XML Mapping Pane from the developer tab.
The default XML schema is selected. Select the CRM XML schema. It will begin with “urn:microsoft-crm/document-template/”.
Expand the CRM entity “account”.
Type in the text required in the document and place the cursor where the CRM data is required. Account Name as in our Example:
From the XML Mapping Pane, right click the entity field, and then click Insert Content Control > Plain Text.
The CRM entity field is mapped to the word template.
To display multiple related records, set the content control fields to repeat. Put fields with repeating data in a table row.
Select the entire table row in the template.
In the XML Mapping Pane, right click the relationship containing the content control fields, and then click Repeating.
The table would be displayed as below:
Design the template as required and Save.
To upload this template into Dynamics CRM, Go to Settings > Templates > Document Templates, then click Upload Template.
Drag the Word file into the dialog box or browse to the file.
And then Click “Upload”.
The new document template record is created.
Now to generate this document, Go to the list of account records > Select an account > select (…) > Word Template > Select the newly created word template (Account Summary_WordTemplate in our case)
Save the file to the local machine.
Open the document. You would have all CRM data mapped to the designed document template.
This new feature can be used to generate simple Dynamics CRM mapped documents. For complex conditional document generation, Dynamics CRM add-on solutions like XperiDo would be handy. But hey, this is just the beginning!