Functions in document templates

From Planfix
Jump to: navigation, search

Functions can be used when automatically formatting documents using templates. Functions simplify how data is displayed in your documents. For example, you can use formulas to automatically display numbers as words or calculate order costs.


To add a formula to a document, use the following syntax: %%%FORMULA%%%.

A FORMULA is an expression for calculating the value of a field, just like in a calculated field.



In the example above, data from the "Service" data tag is added to the formula using the corresponding variables. The two values are multiplied, and the result is the value of the total cost of a specific service or product. The TEXT() function formats the value as a human-readable text string.


All functions available in document template formulas:

The SUM function

SUM() is a function that adds up all values obtained when calculating a formula. It is applied to each element of a multiplying variable.

For example, say you have a "Service" data tag and you want to calculate the total cost of all services in a document. You would use the following function:


In order to get the total cost of services provided, you must multiply the cost of the service by the number of times it was ordered. Here's the formula you should use in your document:


Note that the SUM() function can contain any formula made up of functions.


This is a function that returns a number as words. Only the integer part of the number is written out.


NUMBERASWORDS(number; Output; "language")


  • number is a number or formula
  • Output:
    • 0 - regular output
    • 1 - capitalized output
  • language
    • (empty) — language of user creating document is used
    • ru — Russian
    • en — English
    • uk— Ukrainian

For example, to display a number as words in a document, use the following function:

NUMBERASWORDS(SUM({{DataTag.Service.Cost}}*{{DataTag.Service.Quantity}}); 2; "en")


This function displays the fractional part of a number. You can specify the number of digits after the decimal point you would like to see.


FRACTIONALPART(number; NumberOfDigitsAfterDecimal)

For example, to output the number of cents for the cost of a service in a document, use the following function:

FRACTIONALPART(SUM({{DataTag.Service.Cost}}*{{DataTag.Service.Quantity}}); 2)

This function displays the two digits after the decimal point:

  • 176.03 — function returns 3.
  • 15.15 — function returns 15.
  • 16.156 — function rounds first two decimal points to 16.

Go To