Document Templates – Using Tags in ODF/OOXML Templates

Template Management

For example the Word (.docx, .rtf) and Excel (.xlsx) files and PDF and Open Document format files can be used as document templates for quotes, sales orders, invoices, support tickets, campaigns and invitation events. The templates can be prefilled with images and text. In addition, you can use different tags in the document to include information from the fields of the CRM modules.

An admin can manage the document templates in Settings → Document Templates.

The tags can be used in ODF/OOXML templates and when used in the system, they will be replaced with the input in the field of the entity. You can use the information in the fields of the module the template is linked to and of the modules that are linked to the original module (e.g. Account, Contact, User etc.).

To prevent the data from overlapping in situations where the module has a relation to self or there are multiple relations to the same module, you can use parameters in the document template to specify more precisely where the wanted data is fetched. For example, you can specify that the account name is fetched from the account by using the following parameters:

{{onshow.data.Accounts.accountname}}

In the table below, there are a few examples on how the tags can be used. There are two formats of the tags, either one can be used. NB! In the document templates of Trouble Tickets module, only the form [module.field] can be used.

{{onshow.data.Quotes.subject}}
Subject
{{onshow.data.Quotes.createdtime}}
Created time
{{onshow.data.Quotes.validtill}}
Valid until (date)
{{onshow.data.Accounts.accountname}}
Account’s name
{{onshow.data.Contacts.firstname}}
Contact’s first name
{{onshow.data.Contacts.lastname}}
Contact’s last name
{{onshow.data.Users.first_name}}
User’s first name
{{onshow.data.Users.last_name}}
User’s last name
{{onshow.data.Quotes.cf_1234}}
Custom field of Quotes module (check names always from the CRM supplier)
{{onshow.data.SalesOrder.salesorder_no}}
Sales order’s number
{{onshow.data.SalesOrder.subject}}
Sales order’s subject
{{onshow.data.PurchaseOrder.subject}}
Purchase order’s subject
{{onshow.data.Invoice.duedate}}
Duedate of invoice
[comments.comment]
All the comments from support ticket
[ticket.ticket_no]
Ticket number
[creator.user_name]
Creator’s username
[owner.first_name]
Assignee’s first name
[owner.last_name]
Assignee’s last name

 

The row data of the entity can be linked to the document with the following tags:

{{rows.product_no}}
Product number
{{rows.productname;block=tbs:row}}
Product name including both products and subproducts*
{{rows.productname;block=tbs:row;when {{rows.type}}!='sub'}}
Product names only*
{{rows.productname;block=tbs:row;when {{rows.type}}='sub'}}
Subproduct names only*
{{rows.comment}}
Product description (row description)
{{rows.qty}}
Quantity
{{rows.listprice;frm='0 000,00'}}
List price
{{rows.discount_total;frm='0 000,00'}}
Total discount
{{rows.total;frm='0 000,00'}}
Price (includes discount)
{{rows.grand_total;frm='0 000,00'}}
Total price
(includes VAT and discount)
{{rows.discount_percent;frm='0 000,00'}}
Discount percentage
{{rows.discount_total;ope=div:{{rows.qty}} ;frm='0 000,00'}}
Discount per unit

*If you need the document to automatically add rows according to the row data (e.g. the products are itemized on an invoice), the row tags must be inserted into a table.

 

You can also include a custom row field to the document using the name of the field. For example:

{{rows.cf_lis_ale}}
Field’s name: cf_lis_ale
{{rows.cf_ean_koodi}}
Field’s name: cf_ean_koodi

 

The ‘total’ rows of the invoices, quotes, sales orders etc. are marked with the following tags:

{{total_row.total_no_sub;frm='0 000,00'}}
Total with discount (no sub-products included)
{{total_row.total_before_discount;frm='0 000,00'}}
Total before discount
{{total_row.discount_total;frm='0 000,00'}}
Discount
{{total_row.total;frm='0 000,00'}}
Total with discount
{{total_row.total_tax_no_sub;frm='0 000,00'}}
Tax (no sub-products included)
{{total_row.total_tax;frm='0 000,00'}}
Tax
{{total_row.grand_total_no_sub;frm='0 000,00'}}
Total (includes tax, no sub-products)
{{total_row.grand_total;frm='0 000,00'}}
Total (includes tax)

These tags include the formatting of the number (;frm=’0 000,00′), but it can be left out as well.

To have the information replacing the tag in upper case letters, the following extensions can be used:

  • ;ope=upper (converts all the letters to upper case). For example: {{onshow.data.Accounts.accountname;ope=upper}}
  • ope=upper1 (converts the first letter of the first word to upper case)
  • ope=upperw (converts the first letter of every word to upper case).

A tag that refers to a checkbox typed field will show the value of the field, which is 0 or 1. To change the text shown, the following extension can be used:

  • ;if {{field}}=0;then No;else Yes (if the field hasn’t been checked, the tag will show “No”. If it is checked, “Yes” will be shown). For example {{onshow.data.Accounts.passive;if  {{passive}}=0;then No;else Yes}}.

 

The pictures below show an example on how the tags can be used. The first picture represents the original template:

 

The other picture below shows the result, when the template is used with an invoice:

Module Tools
Document Templates – Convert ODF / OOXML to PDF
Managing and Creating Document Templates
Document Templates – Using Tags in ODF/OOXML Templates
Document Templates: Certificate Templates
Combined Shape