• Release History
  • Documentation
  • Back to www.mscrm-addons.com
  • Release History
  • Documentation
  • Back to www.mscrm-addons.com
home/Knowledge Base/Template Designer(DCP)/Step-by-Step: How to create an invoice template

Step-by-Step: How to create an invoice template

1156 views 0

This article outlines how to create a simple invoice template. 

In this step-by-step description, we will create an invoice template, consisting of general invoice details, the invoice’s products, and tax and discount information.  This template will make use of the following features: 

  • Adding fields from Dynamics 365 
  • Creating relationships 
  • Condition fields 

This guide is based on a sample template. To view the finished sample template, please see the attached document at the bottom of this article. 

For a video version of this guide, please see the video below: 

Step 1: Setting the base entity 

When creating a template, it is always important to set your base entity first.  This is because the fields displayed in the Template Designer will be determined by this base entity, and once a field has been inserted into a template, the base entity can no longer be changed.  In this case, our base entity is Invoice, so we will set the Type accordingly. 

setting the type
Figure 1: Setting the type

Step 2: Adding our text and general structure 

We will begin by including our text and general structure to our template.  For this example, this is what our template looks like. 

text and structure
Figure 2: Our text and structure

Step 3: Adding our standard fields 

To create our invoice template, we need to include some fields that cover the basic information about our invoice, such as details about our customer and the invoice itself.  These standard fields will come either from the Invoice itself, or from its lookup fields 

template with standard fields
Figure 3: The template, now with some standard fields added

Step 4: Adding our table 

For our table, we will create it based on the Invoice Line entity.  We will create it by accessing the Relationship Designer and locating the Invoice->Invoice Line relationship.  Once that relationship has been selected, we will select the Amount, Price Per Unit, and Quantity fields. 

invoice line table
Figure 4: Creating a table based on the Invoice Line entity

After we select the fields, we need to add a Link Element.  This can be found at the bottom of the Relationship Designer. 

adding a link element
Figure 5: Adding a link element

This will bring us to another Relationship Designer window.  Here, we need to select the Product->Invoice Line relationship.  Once that is selected, we must also select the Name field to get the name of our product. 

selecting the relationship
Figure 6: Selecting the needed relationship

With that, click OK on both Relationship Designer windows.  If done correctly, your fields list under the Additional Tab should look something like the following: 

invoice line field list
Figure 7: The field list for our Invoice Line table

To create the table, double click on the Name field.  We will structure our table like so: 

table set-up
Figure 8: Table set-up

Then, we will fill in the fields of our table, and give each column an appropriate name.  We will also add the Total Detail Amount field from the Standard tab in the footer.  Our table now looks like the following: 

our table
Figure 9: Our table

Step 5: Adding our conditional fields 

On top of our table of products, we also want to include some extra fields that show any discounts or taxes that my be applied to our invoice.  However, we only want to include these fields if they are applicable i.e.: if there are no discounts available, we do not display that field. 

This is where Condition Fields come into play.  We can include these fields in our template to do exactly as mentioned. 

We’ll begin by creating a Condition Field through the Insert Fields menu. 

condition field
Figure 10: Selecting the ‘Condition field’ option

We will first create a condition for our discounts.  In our example, we’ll include a name (as highlighted below) and select the Total Discount Amount field.  The operator dropdown will be set to greater than with a value of 0.  It should look something like the following: 

condition field properties
Figure 11: The Condition field properties window.

Click OK.  You should see the following field in your template. 

empty condition field
Figure 12: The empty Condition field in the template

The contents of this field will only be displayed in the result document if the condition is met.  In our case, if the discount is greater than zero (ex: if the field’s value is $20), the contents will be shown in the result document.  It will not be shown if it is zero. 

We want to include a Word table inside of this field and include our Total Discount Amount field as well.  This way, the value of this field will be shown if the condition is met. 

word table in condition
Figure 13: A Word table inside of our condition

This is what we want our condition fields to be structured like in this template.  We will create two other condition fields like this.  However, we want to add in one other field within this condition field: the Join Table field 

The Join Table field can be inserted between two tables to merge them into one table.  In our case, since we want to include two other condition fields similar to the one above, we can insert the Join Table field between the tables to join them into one structure. 

To insert this field, navigate to the Insert Fields menu once more.  You can find this field under the Insert Static Item submenu 

join table field
Figure 14: Locating the Join Table field

Once selected, the Join Table field will be inserted at the location of your cursor.  Please make sure that this field is inserted below our discount table. 

inserted join table field
Figure 15: The Join Table field inserted in our condition, under the Word table

We are now finished with this condition field.  We can proceed to the next field: the Total Tax field. 

tax condition
Figure 16: The Condition Field property window for our tax condition

This condition field is set up just like the one before.  In the end, it should look similar to the following: 

tax condition
Figure 17: The tax condition, with Word table and Join Table field added

For our last condition field, we want to have our Total Amount field displayed only if either the Total Discount Amount or Total Tax is greater than zero.  This can be set up by creating a condition field with two conditions.  To do this, you need only create a condition field like normal and set up two conditions.  Once they have been created, you can select both rows and click the Group OR button. 

using group OR
Figure 18: Grouping two conditions together using ‘Group OR’

This will group them together under a single OR condition statement. 

conditions grouped together
Figure 19: The conditions now grouped together

Click OK.  You can then insert a Word table into the condition field along with the Total Amount field like we have done so far.  Since this is our last condition field, we do not need another Join Table field. 

tax or discount condition
Figure 20: Our tax OR discount condition

Finally, we can adjust the borders on the tables if need be. 

adjusting table borders
Figure 21: Adjusting the borders

Step 6: The result document 

With our fields, tables, and condition fields now in place, we can now test our template.  For reference, this is what our template currently looks like: 

final template
Figure 22: The final template

If we merge it with an Invoice record that we have in our system, this is what we will have as our result: 

merged document
Figure 23: A merged document

Note that the Discount, Tax, and Total rows are all merged thanks to the Join Tables field.  Additionally, the Discount and Tax fields are present since they are greater than zero.  If we change the discount to zero instead, we will find that the row disappears as expected. 

merged document without discounts or taxes
Figure 24: A merged document, with no discounts or taxes present

That’s it! We appreciate your feedback! Please share your thoughts by sending an email to support@mscrm-addons.com. 

Attached Files
#
File Type
File Size
Download
1 .docx 419.27 KB Invoice sample

Was this helpful?

Yes  No
Related Articles
  • Ensuring correct time zone display for DateTime fields
  • How to compare a date-fields with the current date 
  • Create a template for XML or plain text
  • E-Invoicing with DocumentsCorePack
  • How to add content from SharePoint to a document
  • Using MS Word field codes in DocumentsCorePack templates
Latest Articles
  • DocumentsCorePack: Best practices for Dynamics 365 on-premises to online migration projects
  • Multilingual Support in DocumentsCorePack
  • Recap: ColorCloud 2025
  • Configure DocumentsCorePack within custom pages
  • AI-Powered Document Generation with Copilot in Sales
Popular Articles
  • DocumentsCorePack Template Designer – Getting Started
  • Step-by-Step: How to configure a One-Click-Action
  • Application Access for Dynamics 365
  • How to find your environment’s unique name in Microsoft Dynamics 365
  • How licenses are counted
Top Rated Articles
  • “Undefined”-labels in Chrome and Edge 114 and higher
  • Important information for Dynamics 365 online customers using DocumentsCorePack and/or AttachmentExtractor
  • How to activate the DocumentsCorePack Connector for PowerApps & Microsoft Flow
  • How licenses are counted
  • How to insert Condition Fields in DocumentsCorePack Templates designer
Categories
  • *News and General Infos* 62
  • Webinars 44
  • Template Designer(DCP 196
  • DocumentsCorePack(DCP 250
  • TelephoneIntegration (TI 65
  • AttachmentExtractor (AE 72
  • PowerSearch (PS 50
  • ActivityTools (AT 61
  • SmartBar (SB 54
  • GroupCalendar (GC 47
Our Vision

“We see it as our purpose to provide products that simplify and speed up our customers’ Microsoft Dynamics 365 experience.”

Knowledgebase
LogIn
mscrm-addons.com
  • Products
  • Online Shop
  • Downloads
  • My Account
About Us
  • About Us
  • Case Studies
  • Newsletter
  • Partner Program
  • Contact
Support
  • Support
  • Terms & Conditions
  • Documentation
  • Webinars
  • Legal Documents
  • Impressum
  • © 2022 www.mscrm-addons.com. All Rights Reserved.