In Microsoft Dynamics 365 CRM there is an option to create Word Templates. The Word Template feature was introduced in the MS Dynamics CRM 2016. It is useful to create templates for generating documents in a standardized format. To display entity data in standardized format we can export word template. But, these word templates contain the entity metadata (i.e. fields, relationships, etc.) till the template is downloaded.
In our last blog we have seen Word Template feature in Dynamics CRM 2016, in this blog we will see how we can add the new fields of entity in XML Mapping of word template.
Here, on Contact entity we have created a new field with name “Contact Type (new_contacttype)” and this field is not present in XML Mapping of Word Template as shown below.
Below are the steps to add this field in XML Mapping of existing Word Template:
1. We are considering “contact.docx” custom word template file and are adding new fields in this word template.
2. To add new fields in this file, rename “contact.docx” word template file and change extension from “.docx” to “.zip”.
3. Extract “contact.zip” file and you will see the extracted folder as below:
4. Open “customXml” folder from extracted “contact.zip” file and then open “xml” file in editor to add fields.
5. Then add the new field in “item1.xml” file as shown below:
Here, we are adding the field with logical name new_contacttype in XML Mapping of word template. You can add multiple fields like this as well. After adding all necessary fields save the “item.xml” file.
6. Go back to the “contact.zip” folder and navigate to “customXml” folder. Then, replace “xml” file of “contact.zip” file with this edited file.
7. After that rename “contact.zip” and replace extension back to “.docx”.
8. Now, you will see the “Contact Type” field in XML Mapping of “contact.docx” word template as shown below and you can use this field to map in word template.
You can add new fields of Dynamics 365 CRM entity in mapping XML of word templates.