Skip to content

[Step-by-Step Guide] Configure Document Generation Functionality in MS Dynamics 365

Featured Image

Microsoft Dynamics 365 offers the flexibility to create the Microsoft word document that pulls the data from selected CRM entity records, consolidate it automatically and convert it into a pleasing document. In real world MS Dynamics 365 applications, this Document Generation functionality can be used for automated generation of sales quotes, invoices, information summaries and other relevant chronicles.

This blog encompasses end-to-end process of executing Document Generation in Microsoft Dynamics 365 in three steps:

[1] Document Template Configuration
[2] UI for the end user
[3] Implementation of CRM Plugin

I am text block. Click edit button to change this text. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.

[1] Document Template Configuration

[A] Template Creation

In order to configure any document template, first we need base file to create templet design.

  • Follow the path: CRM Instance >> Setting >> Templates >> Document Templates >> Click on the + New button
  • Select Word Template as we are generating the word document, and the Base Entity. Your document will be related to the entity you choose here.
  • Clicking the Select Entity button will navigate you to the page where you can select the desired relationship based on your requirement
  • 2_select-entity
  • Clicking Download Template button will download a blank word file. Open the file and follow the further described steps to create the required template. However, you need to download and configure the new word file for each different entity. Moreover, the word template is also depended on the CRM instance.

[B] Enable Developer Mode

Use the link How to: Show the Developer tab on the ribbon to enable the developer mode

[C] Database Fields Configuration

Database field configuration will capacitate you to generate the document with required data. You need to set the respective identification to fetch the CRM field data to the word document.

Any CRM entity contains the multiple type fields like e.g. Text field, Number Field, Option Set Field, Currency Field etc. You can prepare template for all of these fields. It means, as long as you configure the database fields accurately, you can fetch the data from any number fields into a single document. Follow the described steps to prepare the desired word template.

[i] Add Label: Add label from the control section (To assign the template with image name)

[ii] Follow the path: Content Control >> Controls >> Properties

6_picture-control

[iii] Add applicable Tag: Add the applicable Tag to the label as logical name of the CRM field such as new_prop_rp_name. In fact, Tag value will be used to fetch the relevant data from the CRM field.

 

[iv] Create an Image Template

Having an image or graphics as a part of document is a common practice. It is possible to configure dynamic image fetching from CRM data to the word document. You can fetch the images, which are stored at the other cloud storage location.

  • Add Picture Control from the Controls section8_control-section
  • Resize the image as per the requirement. The generated document will resize the fetched image in the same degree.

 

  • Follow the path: Picture Control >> Control >> Properties10_picture-control
  • Add applicable Tag to the CRM field “new_imagepath”. It will help you in identifying the image/image entity to be fetched.

Once the configuration process is completed, you will able to have the final view of a letter type document as displayed below.

While generating the actual document, system will fetch the relevant actual values described as below.

Similarly, you can have the view of the other predefined documents, which will fetch the actual values.

[v] Upload ready word template to the CRM

  • When you ready with your desired word template, you need to upload it back to the CRM

Follow the path: CRM Instance >> Setting >> Templates >> Document Templates and click the Upload Template button. You will be navigated to the pop up as displayed below. Either browse or drag the Templet file and Upload here.

[2] UI for the End User

After the successful configuration of Document Generation functionality, you need to provide a decent UI for the end user to select the custom template from the available templates. Here are the suggestions:

  1. A Ribbon Button that can display the popup with drop-down list
  2. The Html Web resource to select the files

[3] Implementation of CRM Plugin

  • To implement CRM Plugin, integrate Open XML SDK
  • Manually change the extension of the word file from “.docx” to “.zip” and extract the file. It will have the file structure displayed as be

Moreover, you can perform N number of operations with the word file using Open XML SDK. You can refer the SDK document for the same.

Conclusion

In this blog, I have described the entire process of creating ready to use predefined Microsoft Word templates to be dynamically filled with Microsoft Dynamics 365 CRM field data. In fact, it becomes much straightforward to extract and populate the relevant CRM data using such templates.

Avatar photo
Team Azilen

Azilen Technologies is a Product Engineering company. We collaborate with organizations to propel their software product development journey from Idea to Implementation and all the way to product success.

Related Insights