Document templates that you use in the system can contain text, variables, functions, conditions, and loops. When adding a template to a business process, these components are bound to process context variables so that the generated document is completed with process data.
Variables
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.
начало внимание
Using double quotes (" ") in your templates may result in their incorrect work.
конец внимание
Functions
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, length: number, <from: number>). Removes part of the text according to the specified number of symbols. Example:
начало примера
Example: {Substr({$string1}, 0, 3)} -> Ord
конец примера
начало примера
Example: {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.
начало примера
Example: {ToString({$int1}, astext)} -> five hundred forty-six
конец примера
Please note that fractions cannot be displayed as text.
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.
начало примера
Example: {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.
конец примера
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).
конец примера
Full name
You can insert a person’s full name into a document.
Syntax: ToString(param1: FullName, <format: string>).
Available formats:
- long. Use it to insert the last name, first name, and the middle name.
- short. Use it to insert the last name and the initials.
начало примера
Example:
{ToString({$name1}) -> Winter Alexandra Jean
{ToString({$name1}, short) -> Winter A. J.
конец примера
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")
The phone number is filled in with numbers from left to right. Let’s use 16504998877 as an example.
начало примера
Example:
{ToString({$phone1}, "+1-XXX-XXX-XX-XX")} -> +1-650-499-88-77
{ToString({$phone1}, "X-XXX-XXX-XX-XX")} -> 1-650-499-88-77
{ToString({$phone1}, "XX-XX-XX")} -> 99-88-77
конец примера
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: string, locale: string).
This data type has three options: Date/Time, Date, and Time.
When using the function {ToString({$date1})} without additional arguments, the data in the document will look as follows:
начало примера
Example:
Date/Time: 8/24/22 1:30:00 pm
Date: 8/24/22
Time: 1:30:00 pm
конец примера
If you use the short format in the function ({ToString({$date1}, short)}), seconds won’t be indicated.
When using the long format {ToString({$date1}, long)}, the time will include seconds, and the date the month name:
начало примера
Example:
Date/Time: 8/24/22 1:30:00 pm
Date: August 24, 2022
Time: 1:30:00 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.
To illustrate the use of the ToString() function in document templates, we created an agreement template and completed it with different variables and functions. 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 variable,<locale>).
For example, you can specify the date and time an app item was created.
начало примера
Example:
{DateTime("YYYY–MM–DD hh:mm:ss",{$__createdAt},"en_EN")} —> 2021–01–21 08:30:56
конец примера
Display options: M: month (1) MM: month (01) MMM: month (Jan) MMMM: (January) D: day (2) DD: day (02) DDD: day (Mon) DDDD: day (Monday) YY: year (06) YYYY: year (2006) hh: hours (15) mm: minutes (04) ss: seconds (05) Locales: English (United States): en_US English (United Kingdom): en_GB Danish (Denmark): da_DK Dutch (Belgium): nl_BE Dutch (Netherlands): nl_NL Finnish (Finland): fi_FI French (France): fr_FR French (Canada): fr_CA German (Germany): de_DE Hungarian (Hungary): hu_HU Italian (Italy): it_IT Norwegian Nynorsk (Norway): nn_NO Norwegian Bokmål (Norway): nb_NO Polish (Poland): pl_PL Portuguese (Portugal): pt_PT Portuguese (Brazil): pt_BR Romanian (Romania): ro_RO Russian (Russia): ru_RU Spanish (Spain): es_ES Catalan (Spain): ca_ES Swedish (Sweden): sv_SE Turkish (Turkey): tr_TR Ukrainian (Ukraine): uk_UA Bulgarian (Bulgaria): bg_BG Chinese (Mainland): zh_CN Chinese (Taiwan): zh_TW Chinese (Hong Kong): zh_HK Korean (Korea): ko_KR Japanese (Japan): ja_JP Greek (Greece): el_GR Indonesian (Indonesia): id_ID French (Guadeloupe): fr_GP French (Luxembourg): fr_LU French (Martinique): fr_MQ French (French Guiana): fr_GF French (Reunion): fr_RE Czech (Czech Republic): cs_CZ Slovenian (Slovenia): sl_SI Lithuanian (Lithuania): lt_LT Thai (Thailand): th_TH |
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.
начало примера
The following formats are available:
date -> 8/12/22
time -> 10:52 am
timelong -> 10:52:55 am
datelong -> August 12, 2022
short (default) -> 8/12/22 10:52 am
конец примера
The timezone value must be written in the “America/Toronto” format. You can find the list of available values here.
Barcode function
To encode a String type field in an app and add it to a document as a barcode, use the GenerateBarcode() function. For instance, you can use it to generate a barcode for a contract’s registration number or another unique number assigned to a document. Later you can use this barcode to match the hard copy of a document with its digital version.
You can use barcode scanning software in ELMA365 if you configure an appropriate integration module. Read more about it in Standard modules.
The system allows you to generate barcodes for Word and Excel files.
Syntax: GenerateBarcode(<text: string:1>, <format: code format:2>, <generated barcode’s height in pixels>). Specifying the height is optional.
[1]: the content of the string depends on the format specified in the second parameter.
[2]: available barcode formats and requirements to the string:
- QR Code: any string.
- EAN-8: a string consisting either of 7 digits or of 8 digits (seven digits and a check digit).
- EAN-13: a string consisting either of 12 digits or of 13 digits (twelve digits and a check digit).
начало внимание
If you don’t specify the check digit when using the EAN formats, it will be added automatically. Make sure the data format settings on the barcode scanner allow you to work with these formats.
конец внимание
It is recommended to use the QR Code format, as it can be applied to a greater variety of data, while the EAN formats are limited.
For example, there is a variable $numberstring, and its value is 5901234123457. From this string, a QR code or an EAN-13 can be generated.
начало примера
Example:
{GenerateBarcode({$numberstring}, "QR Code", "125" )}
{GenerateBarcode({$numberstring}, "EAN 13", "125" )}
конец примера
For an EAN-8, the string can only include 8 digits: $numberstring = 59012341.
If a QR code is generated twice based on the same string in a template, but the size in pixels is different, the generated QR codes will be of the same size.
JobPosition() function
This function is used to get a user’s job position.
Syntax: JobPosition(<variable:users>, <format:string>)
You can use the first format to get only the first job position or the all format to get all job positions of a user.
начало примера
Example:
{JobPosition({$__createdBy}, all)} —> The function will pass all job positions of the user specified as the app item’s Author.
конец примера
Conditions
You can display certain text in your document depending on conditions.
A condition starts with {if <condition>} and ends with {end}. Example of a condition: {$variable_name} = "Yes".
Note that for Yes/No switch type variables, you need to specify a value from the Variables field. By default, it can be Yes or No.
There are three types of conditions you can use:
начало примера
Example 1
{if {$user_name} = "John Michael"} Best regards, John Michael {end}
конец примера
начало примера
Example 2
{if {$week.day} = "Friday"}
Have a nice weekend!
{else}
Have a nice day!
{end}
конец примера
начало примера
Example 3
{if {$boolean} <> "No"} This text is displayed {end}
конец примера
Operators
In conditions you can use the following operators:
= equals
<> not equal to
> greater than
>= greater than or equal
< less than
<= less than or equal
For loop
Use the for loop to display a list of items in a document (for example, supplied goods listed one by one).
начало примера
{ 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 items in an app:
начало примера
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:
начало примера
Example
{for fr in {$appListField} }
{$fr} |
{$fr.__name} |
{$fr.money} |
{end}
конец примера
начало внимание
When you work with apps, specify the names of fields in the template without the data prefix.
конец внимание
For loop in tables
To let the loop work correctly, when you add a template to the system, specify the type of data for the variable in the loop.
If you need to extract data from a table into a document, you can use an .xlsx template. For instance, you can extract a list of purchased items with their price, quantity, and the total amount to be paid.
начало внимание
When you work with tables, you need to insert the row.data prefix before names of fields in a template.
конец внимание
When configuring the template, use the for loop and specify the process variable storing the table. The for and end statements need to be placed in the first column of the table; otherwise, the table will not be displayed correctly. Next, enter the codes of the app fields used in the table. For example, for the column that will list the price of each item, enter {$row.data.item_price}, where item_price is the code of the Price field. The row.data code accesses items in the loop and allows you to fill in as many rows in the .xlsx table as there are in the ELMA365 table.
Here is an example of a template for a table displaying the name of the purchased items, their price, quantity, and the total amount to be paid:
Show index number in tables
You can use for for loop to add a row's index number to the table template. This is done via the row.data
prefix and the __index
system property.
For example, a table template with the row number, product name and product price may look like this:
Found a typo? Highlight the text, press ctrl + enter and notify us