Document templates that you use in the system can contain text, variables, functions, conditions, and cycles. 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.
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 each 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:
начало примера
{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.
The syntax for this type of data is as follows: 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 written in digits. Use the astext format to write it as text.
начало примера
Example: {ToString({$int1}, astext)} -> five hundred forty-six
конец примера
Please note that fractions cannot be written as text.
Strings allow you to add text-based information to your document.
The syntax for this type of data is as follows: 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.
The syntax for this type of data is as follows: 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.
конец примера
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.
конец примера
You can convert an amount of money to text in various formats.
The syntax for this type of data is as follows: ToString(param1: money, <format: string>, <locale: string>)
The following format values are available:
начало примера
short -> 1005, 56 (the separator is used according to the selected locale)
sign -> 1005, 56 USD
full -> 1005 dollars, 56 cents
astext -> One thousand and five 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).
конец примера
начало примера
Example:
{ToString({$money1}, full)} -> 1 005 dollars 56 cents
конец примера
You can insert a person's full name into the document.
The syntax for this type of data is as follows: 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.
конец примера
You can set up a mask for phone number input by using the following syntax: ToString({$phone1}, «+7-XXX-XXX-XX-XX»)
The phone number is filled in with numbers from left to right. Let's use 89634998877 as an example.
начало примера
Example:
{ToString({$phone1}, «+7-XXX-XXX-XX-XX»)} -> +7-963-499-88-77
{ToString({$phone1}, «X-XXX-XXX-XX-XX»)} -> 8-963-499-88-77
{ToString({$phone1}, «XX-XX-XX»)} -> 99-88-77
конец примера
You can add a date and time to you template, for example, to specify the delivery date in a supply contract. The syntax for this type of data is as follows: ToString(param1: date/time, <format: string>, <locale: string>)
This data type has various options: Date/Time, Date, Time.
When using the function {ToString({$date1})} without additional arguments or when using the short format {ToString({$date1}, short)}, the data in the document will look as follows:
начало примера
Date/time - 09.04.2019 19:18
Date - 09.04.2019
Time - 15:18
конец примера
If you are using the long formt {ToString({$date1}, long)}, the data will look as follows:
начало примера
Date/time - 09.04.2019 19:18:43
конец примера
Set up the locale: use en-US for English.
начало примера
Example: {ToString({$date1}, short, en-US)} -> 4/11/19 7:15 am
конец примера
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.
Now function
To add the current date and time with regard to your time zone, use the Now function.
The syntax is as follows: Now(<format: string>, <locale: string>, <timezone: string>)
With each format value the date is displayed differently. The following formats are available:
начало примера
date -> date (13.04.2019)
time -> 15:34
timeling -> 15:34:22
dateling -> April 13, 2019
short (dfault) -> 13.04.2019 15:33
конец примера
The timezone value must be written in the America/Toronto format. You can find the list of available values here.
Conditions
You can add or exclude certain text in your document depending on conditions.
A condition starts with the {if <condition>} directive and ends with the {end} directive. <condition> is any condition, for example, {$variable_name} = "true"}
There are two types of conditions:
начало примера
1. {if {$user_name} = «John Michael»} Best regards, John Michael {end}
2. {if {$week.day} = «Friday»}
Bye, have a nice weekend!
{else}
Bye, have a nice day!
{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 cycle
Use the for cycle to display a list of items.
начало примера
{ for fr in {$goods} }
an order placed for - {$fr}
{end}
конец примера
When you upload your template to the system the field assigned to the for cycle is marked as a «list».
To illustrate the use of 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 that we used in this example. |
Tables
If you need to extract data from a table in ELMA365 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 configuring the template, use the for cycle, and specify the process variable storing the table. Next, enter the codes of the app fields used in the table. For example, for a column that would list the price of each item, specify {$row.data.item_price}, where item_price is the code of the "Price" field. row.data allows you to fill in as many rows in the .xlsx table as there are in the ELMA365 table.
A template for a table displaying the name of the purchased items, their price, quantity, and final price may look as follows.
Found a typo? Highlight the text, press ctrl + enter and notify us