Document templates that you use in the system can contain text, variables, functions, conditions, and loops. When adding a template to a business process, you can bind fields of your template with process context variables.
To prepare a template, use:
- Functions:
- ToString() to display different types of data in a variable.
- DateTime() to display the date and time in a certain format considering a locale.
- Count() to display the number of items in a table or app.
- Other special functions —
Barcode
,JobPosition
,PasteImage
,HYPERLINK
, andExtText
. Read more in the Special functions of template syntax article.
- Conditions to display the text that meets a given condition.
- For loop to display data as a list or table.
Variable syntax
All the variables in a template must be unique and have the following form: {$variable_name}
. For example, you can use the {$contractor}
variable to insert the contractor’s name in an agreement created within a business process.
In the template you can use field attributes from the app context, i.e. access nested variables. Available for fields of the Files, Users, App, Arbitrary app, etc. type.
For example, an order has the Contract field (code contract
), where the contract file is loaded, and the Client field (code client
), where the Contacts app item is added. In the generated document you can display the file name or phone number of the client. To do this, the syntax of the template uses the code of the field from the source appl and the code of the nested variable separated by a dot: {$contract.__name}
or {$client.phone}
.
When writing functions, arguments and variable values are enclosed in quotation marks. The following types of quotation marks are allowed: " ", « », “ “, ” ”, ' '.
Functions for working with strings
These functions allow you to display text in different formats.
For illustration, we will use the $string1
variable and the phrase Order shipped as its value.
UpperCase(<param1: string>)
. Converts text to uppercase.
начало примера
Example
{UpperCase({$string1})}
—> ORDER SHIPPED
конец примера
LowerCase(<param1: string>)
. Converts text to lowercase.
начало примера
Example
{LowerCase({$string1})}
—> order shipped
конец примера
Capitalize(<param1: string>)
. Capitalizes the first word in the text.
начало примера
Example
{Capitalize({$string1})}
—> Order shipped
конец примера
Substr(<param1: string>, <from: number>, <length: number>)
. Extracts a part of the text, starting with the specified character<from>
and continuing for the specified number of characters<length>
.
You can fill in only <from>
to keep all the text after the specified character.
начало примера
Examples
{Substr({$string1}, 0, 3)}
—> Ord.{Substr({$string1}, 4)}
—> r shipped.
конец примера
ToString() function
The ToString
function allows you to insert the following data types into your document:
You can read more about the types of data used in the system in the System data types article.
Number
Syntax: ToString(param1: number, <format: string>, <locale: string>)
For illustration we will use the variable $int1
and its value 546.
начало примера
Example
{ToString({$int1})}
—> 546
конец примера
By default, the number is displayed as digits. Use the astext
format to write it as text.
начало внимание
Please note that fractions cannot be displayed as text.
конец внимание
начало примера
Example
{ToString({$int1}, astext)}
—> five hundred forty-six
конец примера
You can specify a locale to output as text in another language. Available locales:
- English:
en-US
oren
- Russian:
ru-RU
orru
начало примера
Example
{ToString({$int1}, astext, en–US)}
—>five hundred forty-six
конец примера
String
Strings allow you to add text-based information to your document.
Syntax: ToString(param1: string)
.
For illustration, we will use the variable $str1
and its value sent for approval.
начало примера
{ToString({$str1})}
—> sent for approval.
конец примера
Category
The Category data type is used for selecting a value from a list, for example, when users choose the payment method: credit card or cash.
Syntax: ToString(param1: category)
.
When a context variable of this type is created in a process, it is given a name and a code. Specify the code in the ToString
function so that the name of the variable is added to the document.
For illustration, we will use the variable $enum1
and payment with credit card as its value: { "code": "card"; "name": "credit card" }
.
начало примера
Example
The selected payment method is {ToString({$enum1})}
—> The selected payment method is credit card.
конец примера
Also, for the Category data type, you can output the category name and code to the template without using the ToString
function.
начало примера
Example
- The selected payment method is
{$enum1.name}
—> The selected payment method is credit card. - The selected payment method is
{$enum1}
—> The selected payment method is credit card. - Code of the used category:
{$enum1.code}
—> Code of the used category is card.
конец примера
Yes/No switch
This data type has two variants: Yes and No. You can rename them, for example, to Approved and Rejected.
For illustration, we will use $bool1 = true
. The Yes variant (yesValue
) is renamed as Approved.
начало примера
Example
{ToString({$bool1})}
—> Approved.
конец примера
Money
You can convert an amount of money to text in various formats.
Syntax: ToString(param1: money, <format: string>, <locale: string>)
.
The following format values are available:
начало примера
Example
short
—> 1,005.56 (separators depend on the locale).
sign
—> USD1,005.56.
full
—> 1,005 US dollars 56 cents.
astext
—> One thousand five US dollars 56 cents.
wildcard
—> you can specify your custom format, for example, {ToString({$money1}, "%i usd %f cents")}
. In this case the amount will be converted to text in the following manner: 1005 usd 56 cents (%i
is the integer part, %f
is the fractional part).
конец примера
You can specify a locale in the function. Available locales:
- Russian —
ru–RU
orru
. - English —
en–US
oren
.
начало примера
Example
{ToString({$money1}, full, en)}
—> 1 005 rubles 56 kopecks.
конец примера
Full name
You can insert a person’s full name into a document.
Syntax: ToString(param1: full name, <format: string>, <case: string>)
.
|
Available case values (for languages where they are applied)
|
If you want to specify a person’s first name, last name, or middle name by itself, use values from the Full name variable, for example, {$executor.fullname.firstname}
, {$executor.fullname.lastname}
, and {$executor.fullname.middlename}
.
Phone number
You can set up a mask for phone number input by using the following syntax: ToString({$phone1}, "+1–XXX–XXX–XX–XX EEE")
The letters in the syntax represent the following:
- X is the main number.
- E is the extension number.
If a user enters the phone number with less digits than the mask represents, the excessive X and E letters will not appear in the document.
The phone number is filled in with digits from left to right.
начало примера
{ToString({$phone1}, "+7—XXX—XXX—XX—XX")}
—> +1-650-499-88-77.{ToString({$phone1}, "X—XXX—XXX—XX—XX EEE")}
—> 1-650-499-88-77 159.{ToString({$phone1}, "XX—XX—XX E")}
—> 99-88-77 3.
конец примера
Date/Time
You can add a date and time to you template, for example, to specify the delivery date in a supply contract.
Syntax: ToString(param1: date/time, <format:>, <locale: string>)
This data type has three options: Date/Time, Date, and Time.
Without specifying any additional arguments, the document displays the current date and time.
начало примера
Example
{ToString({$date1})} ->
- Date/Time: 8/24/25 1:30:00 pm
- Date: 8/24/25
- Time: 1:30:00 pm
конец примера
If you use the short format in the function ({ToString({$date1}, short)}
), seconds won’t be indicated.
начало примера
Example
{ToString({$date1}, short)}->
- Date/Time: 8/24/25 1:30 pm
- Date: August 24, 2025
- Time: 1:30 pm
конец примера
When using the long
format, the time will include seconds, and the date the month name:
начало примера
Example
{ToString({$date1}, long)}->
- Date/Time: 8/24/25 1:30:00 pm
- Date: April 24, 2025
- Time: 1:30:00 pm
конец примера
You can specify a locale
- English:
en-US
oren
- Russian:
ru-RU
orru
начало примера
Example
{ToString({$date1}, short, en–US)} ->
8/24/22 1:30: pm
конец примера
Please note that the Date/Time type takes into account the time zone of your company and shows the date accordingly. The Date and Time types show absolute values.
Then we added it to a business process and bound the template variables to the process variables. During process execution, users fill in the data, and once the process flow reaches the Generate from template activity, the system automatically creates the agreement. Click here to download the template used in this example. |
DateTime() function
The DateTime()
function is used to display date and time in any format. You can also specify the locale.
Syntax: DateTime(<format:string>,<variable:date\time>,<locale>)
.
For example, you can specify the date and time an app item was created.
начало примера
Example
{DateTime(«YYYY–MM–DD hh:mm:ss»,{$__createdAt},"ru_RU")}
—> 2025–01–21 08:30:56
конец примера
The template supports the following quotation marks: " ", « », “ “, ” ”, ' '.
начало примера
Examples
{DateTime('"DD" MMMM YYYY',{$__createdAt},"en_US")}
—> "31" August 2025.{DateTime("«DD» MMMM YYYY",{$__createdAt},"en_US")}
—> «31» August 2025.{DateTime(«'DD' MMMM YYYY»,{$__createdAt},"en_US")}
—> '31' August 2023.
конец примера
Locales: English (United States): English (United Kingdom): German: French: Russian: Spanish: |
Now() function
To add the current date and time with regard to your time zone, use the Now
function.
Syntax: Now(<format: string>, <locale: string>, <timezone: string>)
With each format
value the date is displayed differently.
|
English language en–US
and Russian ru–RU
are available for locale
.
timezone
is set in the format America/Toronto.
начало примера
Examples of function syntax
{Now(datelong, en-US)}
. Long date, en-US.{Now(datelong, en)}
. Long date en.{Now(datelong, en)}
. Date only en.{Now(datelong, ru-RU)}
. Long date ru-RU.
конец примера
Count() function
It gets the number of items passed in a variable of the Table or App type. It can be the number of rows in a table or records in a linked app.
Using this function, you can:
- Display the total number of items to estimate the amount of data.
- Check if there are any data in the variable.
- Display only the number of records instead of the table.
- Specify the number of records above a table or before a list of data, etc.
Syntax: {Count({$variable})}
.
начало примера
Example
{Count({$report_table})}
. The number of rows in the report table.
{Count({$app})}
. The number of items in the linked app.
конец примера
You can also use the function with a for loop.
начало примера
Example
- Show the number of rows of a table that is nested in the main report table:
{for row in {$report_table}}
Subrow count: {Count({$row.execution})}
{end}
- Show the number of rows in the table, which is a property of the linked app:
{for row in {$app}}
Subrow count: {Count({$row.multi})}
{end}
конец примера
Where:
app
is the field that contains the link to another app.row.multi
is a field of the Table type in this app.
Conditions
You can display certain text in your document depending on conditions.
A condition starts with {if <condition>}
and ends with {end}
. <condition>
is any condition, for example, {$variable_name} = "Yes"
.
начало примера
Example 1
{if {$user_name} = "Jacky Jones"} Best regards, Jacky Jones {end}
—> the function's condition checks the user's name. If the name coincides, the specified text is displayed.
конец примера
начало примера
Example 2
{if {$week.day} = "Friday"}
Bye, have a great weekend!
{else}
Bye!
{end}
—> in this example, the current day of the week is checked. Depending on the day, one of the text options will be displayed.
конец примера
начало внимание
When using multiline conditions for .xlsx files, you should not place additional text in the lines with the {if <condition>}
, {else}
and {end}
operators. It will be removed during document generation.
конец внимание
Please note that for Yes/No switch variables you need to specify options from the Options field. By default they are Yes and No.
Начало примера
Example
{if {$options} <> "No"} Example text {end}
—> the text will be displayed only if the value is Yes
.
Конец примера
You can use a function to check if an app item's properties have values. If the field on the form is filled in, you can display its value.
For App or Files properties, the condition function is applied only if there is one value, e.i. the One option is selected for the property. If the Many option is selected, use the for loop.
Начало примера
Example
{if {$document}} {$document} {end}
—> if a document is uploaded to a Files field, its name will be displayed in the generated file.
конец примера
In conditions you can use the following operators:
= Equals
<> Not equal to
> Greater than
>= Greater than or equal
< Less than
<= Less than or equal
OR and AND logical operators
To create complex conditions, you can use the OR
and AND
operators, which allow you to specify multiple conditions as a single construction.
When using OR
, it is sufficient that at least one of the specified conditions is met.
начало примера
Example
{if {$trip.location_type} = "Hotel" OR {$trip.location_type} = "Host apartment"}
{$business_trip_request.city}
{end}
конец примера
When using AND
, you need all of the above conditions to be met.
начало примера
Example
{if {$item.price} < 5000 AND {$item.isAvailable}}
{$item.name}
{end}
конец примера
Conditions with the logical operators OR
and AND
can be combined using parentheses.
начало примера
Example
{if ({$business_trip_request.location_type} = "Hotel" OR {$ business_trip_request.location_type} = "Host apartment") AND ({$business_trip_request.price} < 5000)}
{$business_trip_request.city}
{end}
The address will be specified if all the conditions are met.
конец примера
For loop
Use the for
loop to display a list of items in a document (for example, supplied goods listed one by one).
The loop starts with the {for <expression>}
operator and ends with the {end}
operator. Here <expression>
is a field for a variable that will be defined as a list when the template is loaded into the system and the for
loop is extracted from the document.
начало примера
Example
{for fr in {$goods} }
ordered {$fr}
{end}
конец примера
When you upload your template to the system, and the for
loop is extracted, the field assigned for it is marked as a list.
For loop in apps
You can use the for
loop to display display app data. You can specify field names with or without the data
prefix, such as {$data.appListField}
or {$appListField}
.
начало примера
Example
{for fr in {$appListField} }
Contract {$fr} with {$fr.__name} for {$fr.money}
{end}
конец примера
A similar loop allows you to write data to a table.
начало внимание
For .xlsx files, additional text should not be placed in lines with the {for <expression>}
and {end}
operators. It will be removed during document generation, except for text in merged cells.
конец внимание
начало примера
Example
{for fr in {$appListField} }
|
|
|
{end}
конец примера
For loop in tables
You can display data in the field as a list and as a table. To let the loop work correctly, when you add a template to the system, specify the Table data type for a variable in the loop.
If you need to extract data from a table into a document, for example, a list of goods with their quantity and cost filled in during order processing, you can use a template in .xlsx format.
When configuring the template, use a for
loop and specify the process variable that stores the table data.
When creating a template in a .xlsx file, the for
and end
commands must be in the first column of the table, otherwise the entered text will not be displayed correctly. Next, you need to specify the codes of the corresponding app fields in the template.
In the item_price
function, this is the code for the Price field. In the template, specify it with the row.data
or row
prefix. For example, {$row.data.item_price}
or {$row.item_price}
. The prefix refers to the item in a loop and allows as many rows to be filled in the document as are filled in the table in BRIX.
начало внимание
In table rows with the {for <expression>}
and {end}
operators, additional text should not be placed. It will be removed during document generation, except for text in merged cells.
конец внимание
A .xlsx document template for a table that contains an item, its cost, quantity, and total amount payable may look like this:
You can also add an if
condition to the for
loop. You can see an example in the Templates for approval sheets and lists of informed users article. Please note that for .xlsx files, you should not place any text in rows with the {for <expression>}
and {end}
operators, as this text is deleted during generation. The exception is vertically merged cells.
Template for a table in a .docx file
To generate a table from a template in a .docx file:
- Separate the first row of the table using the Split table option.
- In the empty row that appears, declare a
for
loop. - Configure the template in the table by specifying variables from the business process context.
- Under the table, close the loop with the
end
command.
For example, the template for a table in a document might look like this:
Nested tables
The for
loop can be used to create a nested table. When referencing columns of a nested table, instead of prefix row.data
or row
use a different prefix — subrow.data
or subrow
.
Please note that in rows with operators {for <expression>}
and {end}
, you cannot place any other text as it will be deleted during generation. Cells merged vertically are an exception. For example, when generating a document from such a templte, the value of variable {$row.author}
will be shown in the table:
Show index number in tables
You can use for
loop to add a row's index number to the table template. This is done via the row.data
or row
prefix and the __index
system property. For example, {$row.__index}
.
A table template with the row number, product name and product price may look like this:
Found a typo? Select it and press Ctrl+Enter to send us feedback