1-Click Document Generation in CRM 2016 (Web and Mobile)

Formalized documents are a cornerstone of business dealings – from quotes and contracts to work orders and invoices. Leveraging CRM data to automatically generate these documents from standardized templates enhances productivity, reduces human error and ensures standardized communication across the company

In CRM 2016 you can 1-click generate documents for any end-user facing entity.

In this article we'll first take a look at how you can create a document based on one of the standard templates included in the sample data. Then we will see how you can create your own templates. The templates will be available for you to use in the web as well as the mobile app.

How to create a document based on a standard template

To see a list of available templates in Dynamics CRM 2016 navigate to SettingsBusiness - Templates
   Figure 1 

Click Document Templates to open the "Available Templates View"


   Figure 2 

In the "Available Templates View" note there are a number of Microsoft Excel and Word templates, including a Word Template “Opportunity Summary” (1). We'll create a document based on this template.


   Figure 3 

If you open the template you see that the Associated Entity Type is Opportunity (1). This means that you can use this template from any Opportunity record


   Figure 4 

Lets navigate to SalesOpportunitiesMy Open Opportunities (1) and open an Opportunity record, e.g. "Will be ordering a 110 items...." (2)


   Figure 5 

In the opportunity form click the More menu (1) – Word Templates (2) – Opportunity Summary (3)


   Figure 6 

Note – you can *create* a new template from this menu too

The document based on the templates downloads to your computer (1)


   Figure 7 

Open the document from the download location and notice the values from the opportunity is merged into the document, e.g. the Subject (1) and the Current Situation (2)


   Figure 8 

How to create your own template

You create templates using the XML Mapping Pane in Microsoft Word. To do that you download empty templates (Word documents( from CRM that has an XML attached (OpenXML) for CRM attributes and related entities. Then you insert controls into the Word document, and finally upload the template back into CRM. The uploaded templates can be used across the organisation or individuals.

Steps

  1. Navigate to any CRM entity OR Settings -> Templates -> Document TemplatesUse “New” to download a new blank template. This is your starting point
  2. Select between Word or Excel Templates
  3. You will get a file download. This is your base template
  4. When you open up Word, you need to enable XML Mapping pane under Developer Panel to start
  5. Once you’re done editing, upload back into CRM. This will create a “template” entity
  6. Now anyone with access to the template entity can generate a document in 1 click

Lets look at how to create a new Template with the Associated Entity Type = Lead.

To test it out create three tasks for one of your leads

We’ll create a simple Word template that lists the Lead's Topic (1) field as well as the three tasks (2-4) with their subjects and due dates


   Figure 9 

To create a new template navigate to SettingsBusinessTemplates and click New (1)

    Figure 10 

Select to create a Word template (1)


Figure 11

Pick the Lead entity to filter by (2)


   Figure 12 

Click Select Entity to display the "Select Entity" dialog


   Figure 13 

The relationships you select in the "Select Entity" dialog determine what entities and fields are available later when you define the Word template. Only select relationships you need to add CRM data to the Word template

Check the Lead-Task 1:N Relationship (1) enabling you to list the Lead’s three tasks as discussed earlier. Then click Download Template (2) to download the template to your computer


   Figure 14

The template is downloaded (1)


   Figure 15 

You can find the downloaded template (1) in your designated Downloads folder on your file system. Note the name is auto generated from the entity type and timestamp.

Double-click the document to open the template in Word


   Figure 16 

At this point the template is empty (a blank document). What you need to do next is enable the Developer tab and then use the XML Mapping Pane to insert your CRM Lead fields into the template


  Figure 17 

To enable the Developer tab click FileOptionsCustomize Ribbon (1) – and check the Developer checkbox (2). Then click OK (3) to close the Word Option dialog and return to the Word Template


   Figure 18 

Click the now visible Developer tab (1) to display the Developer ribbon


Figure 19

In the Developer ribbon click the XML Mapping Pane to display the XML Mapping Pane


Figure 20

Expand the "Custom XML Part" drop down (1)


   Figure 21 

And pick the schema urn:microsoft-crm……. (1) to show the Lead fields


   Figure 22 

The Lead fields is now available to you.


   Figure 23 

Start designing your template. E.g. type “For the lead:”

Then in the task pane right-click the subject field (1) – click Insert Content Control (2) – click Plain Text (3) to insert the subject field


   Figure 24 

The subject field inserted in the template (1)


   Figure 25 

Now in the task pane scroll down to "Lead_Tasks" (1) and expand the section to see the available task fields


   Figure 26 

Continue designing your template, e.g.. using the normal Word Table feature to insert a 2x2 table. Type headers, e.g. Subject and Due (1). The table will eventually be used to list the three tasks each in separate rows.


   Figure 27 

In the left cell in the lower row insert the subject field (1) and in the right cell insert the scheduledend field (2)


   Figure 28 

To make the last row a repeating row (there is three tasks in the lead), select last table row (1)

Then in the task pane right-click "Lead_Tasks" (2) – click Insert Content Control (3) – click Repeating (4)


    Figure 29 

The last row is now a repeating row.


   Figure 30 

Save the template with your desired name (1) in a location (2) you can remember (in this example perhaps use the name My_Lead_Tasks_Template_v1)


   Figure 31 

Back in CRM navigate to Settings – Business – TemplatesDocument Templates, and  in the "Available Templates View" click Upload Template (1) to display the "Upload Template" dialog


   Figure 32 

Drag your template from the File System folder (1) to the "Upload Template" dialog (2)


   Figure 33 

Click Upload (1)


   Figure 34 

Note that the template is uploaded with the name you chose when saving in Word (1) and Associated Entity Type = Lead (2)


   Figure 35 

Back in the "Available Templates View" you see your new template listed with your name under Modified By (1)


   Figure 36 

To test your new template navigate to the "My Open Leads" view and click the lead you created with the three tasks (1)


   Figure 37 

Click the More menu (1) – click Word Templates (2) and then click My_Lead_Tasks_Template_v1 (3) or the name you chose to create and download the document


   Figure 38 

The document is downloaded (1). Open the document in Word.


   Figure 39 

Note that the Topic value is inserted after the colon in line #1 (1) and the three tasks are inserted in the table with their subjects and due dates (2-4)


   Figure 40 

Using the template in your CRM for Phones app

Open your app and navigate to Leads

Open the lead and click the dots in the lower right corner to open the menu

Click Word Templates

Click your template

Confirm that you wish top open the document in Word Mobile

And voila - you are ready to edit the document

I hope you will enjoy and benefit from this new 1-click generate documents for any end-user facing entity feature.

Note

  • Related Entities will be 1 level deep.
    We will add support for more levels in future. Currently relationship selector only goes 1 level. Also note that lookup fields do not have support for fully accessing the lookup’s data yet beyond primary field
  • Org templates/personal templates
    Similar to Excel we’re modelling security based on template record ownership. So you can have org level templates, or team/user level. Only admins can create org-level templates. Since its based on entity security, you can share/assign templates

See also

  • Using Word templates in CRM - link