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.


Used to append a suffix to a word or to change the word itself if it is an irregular noun based on the number given before it in the document template.


PLURALFORM (number; "text1"; "text2";)

Depending on the calculated value of the number, the function selects one of two parameters. The parameters must be specified in strict order according to the algorithm.

For example, you need to inflect the word "ruble." Follow the algorithm:

First, write the required word with the number 1:

  • 1 ruble

This means that the first parameter in the function "should be the word "ruble" instead of "text1".

Then, write the word with the number 2:

  • 2 rubles

This means that the second parameter in the function "should be the word "rubles" instead of "text2".

Finally, you can specify the following PLURALFORM() function in the document:

PLURALFORM(SUM({{Datatag.Service.Cost}}*{{Datatag.Service.Quantity}}); "ruble"; "rubles")


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