In one of our previous blog posts, we offered up an excellent example of how to generate consistently formatted one click Microsoft Word documents. In today's blog, we are going to dive even deeper into that post and show you how to add and format a table in the document to have automatically repeating rows should there be more than one row of data that needs to be displayed from CRM. Let's start the steps!
1. First, download the Word template document that contains the CRM XML mapping information.
2. Insert a Word table that contains a sufficient number of columns for the CRM data and at least two rows (you may want a third for a 'Total' line or cell), of which the first will contain the column headers for the CRM data.
3. Add the column headers in the first row, and in the second row, add the fields from the mapped XML relationship. The last cell in our third row in this example is from the CRM rollup field total.
In order to make the field(s) row automatically repeat to accommodate all of the CRM data:
1. Select the entire row that contains the CRM fields.
2. Right-click on the XML mapping header that contains the included fields.
3. Hover over 'Insert Content Control' to reveal 'Repeating'.
4. Left-click on 'Repeating' to make the row automatically repeat as needed.
There should now be a + sign at the end of the selected row indicating that the row is automatically repeating.
As mentioned above, the third row, rightmost cell has been populated with the field that holds the calculated total for dataset within CRM and is obviously not repeating. Additional content may be added to enhance the presentation of the final document (i.e. in this example, separate areas of the document contain the Company name and Estimated Close Date from CRM via XML mapping as well as a Company logo). The completed template will be similar to the example below:
The document template is now ready to be uploaded into CRM per the instructions in the original blog.
To generate the document based on the new template from within CRM, follow these steps:
1. Navigate to the desired record (in our example, an Opportunity record was modified and used for purposes of this demonstration).
2. In the Command Bar, click on the ellipses, select Word Templates, and select the target template (1-Click Opp ProdLineItem in this instance).
The results will be similar to the document shown below. Note here that the Line Total and Grand Total are based on the Negotiated Price and Quantity, not the Base Price. The Grand Total was calculated within CRM and pushed to the generated document.
That's all for the blog today! Check out a video of our five favorite features in Dynamics CRM 2016 to learn more about the latest and great version of CRM from Microsoft!