Office Open XML has been invented to enable the creation of very complex templates that would normally require the use of macros. This article contains a step-by-step description of how to create such a template.
As for demonstration purpose, we decided to create a so-called quote-with-grouping-template in this example, because it is most likely used by Microsoft Dynamics CRM users.
(Quote-with-grouping means that the quote-products are grouped by the value of a specific CRM-attribute, for example, subject.)
Step 1: Create a template layout by selecting an entity
First, we need to create the basic layout of the template. Clicking on the
[Insert MailMerge Fields]-menu button in the www.mscrm-addons.com command bar will open the DocumentsCorePack Template Designer.
Now, to create the basic layout for, e.g. a quote-with-grouping-template, we must select the type Quote in the Type-Selector-Dropdown Menu. Each template is based on a specific entity.
Step 2: Insert Fields
Now that we have selected an entity, we need to insert fields into our template. To do so, we set the cursor at the position where we would like to insert a certain field. Then, we double click the field name. You could as well insert it via the [Insert field]-button. For more information on the [Insert field]-button, have a look at this article.
Once you have inserted all the fields you would like to insert, your template could look like this:
Step 3: Add line-item relationship
The next step is to resolve the quote-quote product relationship. To do so, we need to click on the Additional-tab in the DocumentsCorePack Template Designer. The Additional section allows us to resolve any relation/entity within CRM and brings up a list of all attributes from the related entities so that they can be used within the document too.
Here, we click on the [Add Relationship/Entity]-button in order to add a new relationship.
We use the “Configure fields and data source” – dialog to resolve the fields, tables, and relationships we need for our document.
In our example, we must select Quote -> Quote Booking Product [msdyn_quote]. As a result, the available fields of this relationship are displayed in the Attributes field of the “Configure fields and data source dialog”.
As soon as we click on the [OK]-button, all the selected fields will be related to the Quote Product table.
Please note: Only the fields checked in the Attributes field will later be visible in the DocumentsCorePack Template Designer.
Step 4: Insert the table
The procedure of inserting a table of items is completely automated, so we just need to set the curser to the position where we want to add the table and double click on one of the fields that we have previously added to the table. As soon as we do so, a dialog (see Figure 8) appears.
Within this dialog, you can select between three possibilities of how the fields should be inserted to the table.
In our example, we want to insert a new table with a header and a footer. So we select the corresponding options and click on the [OK]-button.
As a result, the table will be inserted at the determined position:
Step 5: Format the table
Once we have inserted the table, we can add fields like quantity, product-name, or even a table header including column-names with the formatting options available in the www.mscrm-addons.com – tab.
With a click on the Rows and Columns – Dropdown, you get the possibility to split or merge the columns, to insert a right or left column, to delete a row or a table and to add a header or a footer row.
Please note: It is of utmost importance to insert the header, as well as the footer, exclusively via the www.mscrm-addons.com – tab in the command bar! Do not enter them via Microsoft Word!
Step 6: Get the result
After saving the document and selecting our CRM-data we can see the result with the replaced fields at the top, the line item table including the sum in the middle, and the bank-details at the bottom.
Figure 12: DocumentsCorePack template – Result
That is how you create a DocumentsCorePack template!
That’s it! We appreciate your feedback! Please share your thoughts by sending an email to email@example.com.