List of functions for generating documents by a template v3.10

Generation by Template

In ELMA, you can generate documents, notifications, object instance names by a template.

Functions always return a line of the specified format, therefore you can use the functions described in this article in any names.

 
The functions are applicable to ELMA 3.10.10 and higher.

List of template generator functions

Standard functions:

Functions for working with the calendar:

Functions for working with reminders:

Functions for working with the CRM model:

Functions for signing texts:

Functions for inclining words and phrases (Russian):

Functions for generating projects:

Functions for working with time intervals:

Formatting functions:

Functions for generating notifications:

Functions for working with users:

Functions for working with time report items:

Functions for working with tasks:

Below is a table with the list of functions with descriptions and examples.

Required parameters are marked with an asterisk (*).

 

Standard functions

Name

Description

Count

Returns the number of items in a block.

Function parameters:
[0]*: block or block item

Result: number of block items.

Example: assume a Goods variable of the Block type, which has the properties: Name and Quantity. To display the values of this variable in a template, use:
{for Item in{$Goods}}
{$Item.Name}: {$Item.Quantity} pcs.{end}
To get the number of block elements:
{Count({$Goods})}
Inside a cycle you can use the following expression:
{Count({$Item})}

Index

Returns the current position in the block (starting with 0).

Function parameters:
[0]*: Block item

Result: current index in the block.

Example: assume a Goods variable of the Block type, which has the properties: Name and Quantity. To display the values of this variable in a template, use:
{for Item in{$Goods}}
{$Item.Name}: {$Item.Quantity} pcs.{end}

To get the current position in the block, use:
{Index({$Item})}

Image

Adds an image to the template.

Function parameters:
[0]: Variable of the File (system) type
[1]: Image display format (string) 

Note: a string with a scale value of the Double type as scale:(scale value) is passed as a format

Result: an image of the specified format will be added to the template.

Example: assume a FileWithImage - variable of the File (system) type, which contains an image.
To display the image in the template with 10% scale, use the following expressions: 
{Image({$FileWithImage};’scale:10’)}

HtmlString

Returns a string in HTML.

Function parameters: 
[0]*: A string with html code (string) 

Result: the source string in HTML. 

Example: assume a String variable of the String type. To represent String in HTML, use the following expression:
{(HtmlString({$String})}

StringCut

Allows trimming a string to the specified number of characters.

Function parameters: 
[0]*: String (string) 
[1]*: Maximum string length (int) 

Result: if the length of the input string is more than the MaxLength value, then the string will be trimmed to MaxLength minus two characters and ".." will be added at the end. Otherwise, the string is not trimmed.

Example: 
StringCut(‘Fall, puddle’, 10) 
(Result: ‘Fall, pu..’)

Functions for working with the calendar

GetCalendarEventMembers

Returns the list of the event participants, depending on their status.

Function parameters: 
[0]*: Событие (ICalendarEvent) 
[1]*: Event participant status (int) 

Allowed values: 
Participant (0);
Informed (1).

Result: list of event participants with the specified status.

Example: assume an Event variable of the Event type. To get the list of the event participants, use the following expression:
{GetCalendarEventMembers({$Event};0)}


To get the list of participants, who should be informed, use:
{GetCalendarEventMembers({$Event};1)}

Functions for working with reminder

GetReminderTimeSpan

Returns the value of the time interval before sending a reminder about the event start or end (for tasks).

Function parameters: 
[0]* - Reminder (IReminder) 

Result: time period before the reminder is triggered. Specified as "w. d. h. min."

Example: create a task and specify its duration from 23.05.2017 till 25.05.2017 12:00. Next, set a reminder about the task end for 24.05.2017 9:00.
Assume a Reminder variable of the Reminder type. Then to get the time before the reminder is sent, use the following expression: 
{GetReminderTimeSpan({$Reminder})} 

Function result: "1 d. 3 h".

Function for working with the CRM module

GetRelationshipMembers

Returns the list of the relationship participants.

Function parameters: 
[0]*: Relationship (IRelationship) 
[1]*: Relationship participant status (int) 

Allowed values: 
- "Participant" (0);
- "Informed" (1).

Result: list of users, who participate in the event with the specified status. 

Example: assume a Relationship variable of the Relationship type. To get the list of the event participants, use:
{GetRelationshipMembers({Relationship};0)} 
To show the participants who should be informed, use: 
{GetRelationshipMembers({Relationship};1)}

PropertyRowIfCategory

Allows getting changes in the list of categories.

Function parameters: 
[0]*: Old categories hash (string) 
[1]*: New categories hash (string) 

Result: depending on the context generation mode, the function shows the changes in the list of categories. If HTML is selected as the notification generation mode, then a table with new and old categories is created. Otherwise, a string with new categories is created.

Example: assume Old and New are old and new values of a Contractor-type variable. To display the list of categories, use the expression:
{PropertyRowIfCategory({$Old.CategoriesHash};{$New.CategoriesHash})}

Attention! This is a system function, and it is not recommended that you use it!

Functions for signing texts

TransformFileToSignedText

Allows converting a file into a signed text.

Function parameters: 
[0]*: File (BinaryFile) 

Result: returns the signed text as the result of converting the file.

Example: assume a BinaryFile variable of the File type. To get the signed text, use the expression:
{TransformFileToSignedText({$BinaryFile})}

Functions for inclining words and phrases (Russian)

ФОРМАТ_ФИО

Returns a full name in the specified format and case.

Function parameters: 
[0]*: String with a full name (string) 
[1]: Case (1 = Nominative, 2 = Genetive, etc.) (int) 
[2]: Full name display format. (string) 

Allowed formats: 
- "фамилия" or "ф"; 
- "имя" or "и"; 
- "отчество" or "о". 

Result: expression converted to the specified format and case.

Example: to get a full name in the genetive case, use the following expression:
{ФОРМАТ_ФИО(‘Иванов Иван Иванович’, ‘Р’)} 
Result: "Иванова Ивана Ивановича".

Просклонять

Returns the specified string in the specified case (is a Russian counterpart of the "Incline" function).

 

Incline

Returns the specified string in the specified case (is an English counterpart of the "Просклонять" function).

Function parameters: 
[0]*: String with expression to incline (string) 
[1]: Case ("и" or "именительный", "р" or "родительный", etc.) (string) 
By default, "именительный"
[2]: Additional parameters (params string[]) 

Allowed values: 
- "фио" ("ф");
- "мужскойрод" ("м");
- "женскийрод" ("ж");
- "нарицательное" ("н");
- "одушевленное" ("о");
- "неодушевленное" ("но").

Result: the phrase, converted according to the specified format.

Example: to get a string in the specified case, use the following expression:
{Incline(‘Моё словосочетание’;‘П’)}
As the result, you get the following expression "о Моём словосочетании"
or
{Incline(‘Любовь’;‘Д’;’ф’)} 
Result - "Любови" 
or
{Incline(‘Любовь’;‘Д’;’н’)} 
Result - "Любви".

ПросклонятьМнож

Returns a string in plural and in the specified case (is a Russian counterpart of the "InclineMany" function).

 

InclineMany

Returns a string in plural and in the specified case (is an English counterpart of the "ПросклонятьМнож" function).

Function parameters: 
[0]*: A string with an expression to incline (string) 
[1]: Case ("и" or "именительный", "р" or "родительный", etc.) (string) 
By default, "именительный". 
[2]: Additional parameters (params string[]) 

Allowed values: 
- "фио" ("ф");
- "мужскойрод" ("м");
- "женскийрод" ("ж");
- "нарицательное" ("н");
- "одушевленное" ("о");
- "неодушевленное" ("но").

Result: the phrase in plural, converted according to the specified format.

Example: 
{InclineMany(‘Моё словосочетание’;‘П’)} 
(Result: "о Моих словосочетаниях").

ЧислоВСтроку

Returns a number in a text format and in the specified case (is a Russian counterpart of the "NumberToString" function).

 

NumberToString

Returns a number in a text format and in the specified case (is an English counterpart of the "ЧислоВСтроку" function).

Function parameters: 
[0]*: A number to convert to a string (any number type, except byte);
[1]: Case ("и" = "именительный", "р" = "родительный", etc.) (string);
By default, именительный;
[2]: Units of measurement. (string) 
Allowed formats: 
- For the integer part only ("рубль");
- For the fraction part only ("копейка");
- Integer and fraction parts ("рубль|копейка").
Default value: "целый|десятый"
[3]: Amount of units of measurement (all number types, except byte). 
Be default, 100 
[3-4]: Number display format (string).

Allowed formats: 
- "0" - for displaying the fraction part only;
- display format ID ("A", "B", etc.). "A" and "B" are system IDs;
Users can create custom formats and assign them with IDs: 
- a composite format, consisting of a sequence of templates.
Allowed templates: 
- {ЦЧ} {ЦелаяЧасть} (template for displaying the integer part of the number);
- {ДЧ} {ДробнаяЧасть} (template for displaying the fraction part of the number);
- {ЦЧ:Ф} {ЦелаяЧасть:Ф} (template for displaying the integer part of the number using a display format);
- {ДЧ:Ф} {ДробнаяЧасть:Ф} (template for displaying the fraction part of the number using a display format);
- {ПЦЧ} {ПрописьЦелойЧасти} (template for displaying the integer part of the number spelled out);
- {ПДЧ} {ПрописьДробнойЧасти} (template for displaying the fraction part of the number spelled out);
- {НЦЧ} {НаименованиеЦелойЧасти} (template for displaying the measurement units of the integer part);
- {НДЧ} {НаименованиеДробнойЧасти} (template for displaying the measurement units of the fraction part).
By default, "{ПЦЧ} {НЦЧ} {ПДЧ} {НДЧ}" 
You can find examples of the "Ф" value here

Result: the number converted to an equivalent string in the specified format.

Example: if you use the expression:

{ЧислоВСтроку(123.5;’Р’;’бочка|литр’;122;’{ЦЧ} ({ПЦЧ} {НЦЧ}) {ДЧ} ({ПДЧ} {НДЧ})’)} 
the result will be: 123 (ста двадцати трёх бочек) 61 (шестидесяти одного литра)) 
or
{NumberToString(12345.5;’Д’;’бочка|литр’;122;’{ЦЧ:N} ({ПЦЧ} {НЦЧ})’)} 
Result: 12 345,00 (двенадцати тысячам трёмстам сорока пяти бочкам).

ИзменитьРод

Allows changing the gender of an adjective (is a Russian counterpart of the "ChangeKind" function).

 

ChangeKind

Allows changing the gender of an adjective (is an English counterpart of the "ИзменитьРод" function).

Function parameters:
[0]*: An adjective in nominative case, masculine gender (string)
[1]*: Gender and number to convert to (string) 

Allowed formats: 
- "Мужской род" ("м", "муж"); 
- "Женский род" ("ж", "жен");
- "Средний род" ("с", "ср");
- "Множественное число" ("мн", "множ").

Result: the adjective, converted according to the specified format.

Example: is you use the expression:
{ИзменитьРод(‘спокойный’;’ЕдинСред’)} 
as the result you get: "спокойное"
or
{ChangeKind(‘спокойный’;’жен’)} 
Result: "спокойная".

ФамилияПротивоположногоПола

Allows getting the last name of the opposite gender (is a Russian counterpart of the "AnotherGenderSecondName" function).

AnotherGenderSecondName

Allows getting the last name of the opposite gender (is an English counterpart of the "ФамилияПротивоположногоПола" function).

Function parameters:
[0]: A string with the last name (string) 

Result: a string the last name of the opposite gender. 

Example: 
{ФамилияПротивоположногоПола(‘Петров’)} 
Result: "Петрова".

РодИлиЧисло

Allows getting the gender and number of an expression (is a Russian counterpart of the "KindOrNumber" function).

KindOrNumber

Allows getting the gender and number of an expression (is an English counterpart of the "РодИлиЧисло" function).

Function parameters: 
[0]*: A string with an expression (string) 
[1]: Additional parameters (params string[]) 

Allowed values: 
- "фио" ("ф");
- "мужскойрод" ("м");
- "женскийрод" ("ж");
- "нарицательное" ("н");
- "одушевленное" ("о");
- "неодушевленное" ("но").

Result: gender or number of the expression. For words like "брюки, ножницы, etc." plural is returned.

Example: if you use the expression
{РодИлиЧисло(‘спокойный’)} 
as the result you get: "Мужской род".
or
for {KindOrNumber(‘брюки’)} 
you get: "Множественное число".

Фио

Allows getting the full name or a part of it (is a Russian counterpart of the "GetPartOfFullName" function).

GetPartOfFullName

Allows getting the full name or a part of it (is an English counterpart of the "Фио" function).

Function parameters: 
[0]*: A string with a full name (string)
[1]*: A part of a full name

Allowed formats:
- "фамилия" ("ф");
- "имя" ("и");
- "отчество" ("о");
- "полноеимя" ("полн").

Result: the full name or its part according to the specified format

Example:
{Фио(‘Пушкин Александр Сергеевич’;‘о’)} 
Result: "Сергеевич".

ЯвляетсяФио

Allows identifying, whether an expression is a full name (is a Russian counterpart of the "IsFullName" function).

IsFullName

Allows identifying, whether an expression is a full name (is an English counterpart of the "ЯвляетсяФио" function).
Function parameters: 
[0]*: A string with a full name (string) 
[1]: Additional parameters (params string[]) 

Allowed values: 
- "фио" ("ф");
- "мужскойрод" ("м");
- "женскийрод" ("ж");
- "нарицательное" ("н");
- "одушевленное" ("о");
- "неодушевленное" ("но").

Result: True will be returned is the expressions is a full name, otherwise, False. 

Example: for the expression
{ЯвляетсяФио(‘Пушкин Александр Сергеевич’)} 
the result is "True".

ЯвляетсяОдушевленным

Allows identifying whether an object in an expression is animate (is a Russian counterpart of the "IsAnimated" function).

IsAnimated

Allows identifying whether an object in an expression is animate (is an English counterpart of the "ЯвляетсяОдушевленным" function).

Function parameters: 
[0]*: A string with an expression (string) 
[1]: Additional parameters (params string[]) 

Allowed values: 
- "фио" ("ф");
- "мужскойрод" ("м");
- "женскийрод" ("ж");
- "нарицательное" ("н");
- "одушевленное" ("о");
- "неодушевленное" ("но").

Result: True will be returned if the object in the expression is animate, otherwise, False.

Example: for the expression
{ЯвляетсяОдушевленным(‘заяц’)} 
Result: "True".

Functions for generating projects

IsProjectTaskDelayed

Allows identifying, whether the passed task is delayed, i.e. whether it falls within the task display interval in the project.

Function parameters: 
[0]*: Project task (IProjectTaskBase) 

Result: True will be returned if the task is active and not visible in the user's task list and if one of these conditions is met: 
1. the passed task is delayed and an early start is not allowed for it;
2. there are active linked tasks, on which this task depends.
Otherwise, False will be returned.

Example: assume a ProjectTask variable of the Project Task type. To identify, whether the task is delayed, use the expression: 
{IsProjectTaskDelayed({$ProjectTask})}

IsProjectTaskTemplate

Allows identifying whether the passed task is a project template.

Function parameters:
[0]*: Project task (IProjectTaskBase) 

Result: True will be returned, if the passed task is a project template. Otherwise, False will be returned. 

Example: assume a ProjectTask variable of the Base Project Task Class type. To identify, whether the ProjectTask is a project template, use the expression:
{IsProjectTaskTemplate({$ProjectTask})}

Functions for working with time intervals

ИнтервалВремениВСтроку

Allows representing a time interval as a string (is a Russian counterpart of the TimeSpanToString function)

 

TimeSpanToString

Allows representing a time interval as a string.

Function parameters: 
[0]*: Time interval (TimeSpan) 

Result: string representaion of a time interval as "d. h. min. sec."

Example: assume a TimeSpan variable of the Time Span type. Its value: 128.17:30:33.3444555. Then for the expression: 
TimeSpanToString({$TimeSpan}) 
The result is: 128 d. 17 h. 30 min. 33 sec.

ПолучитьДниИнтервала

Returns a time interval (in days) as a string (is a Russian counterpart of the GetTimeSpanDays function).

GetTimeSpanDays

Allows representing a time interval (in days) as a string.

Function parameters: 
[0]*: A time interval (TimeSpan) 

Result: the interval days as a string.

Example: assume a TimeSpan variable of the Time Span type. Its value: 128.17:30:33.3444555. Then for the expression: 
GetTimeSpanDays({$TimeSpan}) 
The result is 128.

ПолучитьЧасыИнтервала

Returns a time interval (in hours) as a string (is a Russian counterpart of the GetTimeSpanHours function)

 

GetTimeSpanHours

Returns a time interval (in hours) as a string.

Function parameters: 
[0]*: A time interval (TimeSpan) 

Result: the interval hours as a string.

Example: assume a TimeSpan variable of the Time Span type. Its value: 128.17:30:33.3444555. Then for the expression: 
GetTimeSpanHours({$TimeSpan}) 
The result it 17.

ПолучитьМинутыИнтервала

Returns a time interval (in minutes) as a string (is a Russian counterpart of the GetTimeSpanMinutes function).

 

GetTimeSpanMinutes

Returns a time interval (in minutes) as a string.

Function parameters: 
[0]*: A time interval (TimeSpan) 

Result: the interval minutes as a string.

Example: assume a TimeSpan variable of the Time Span type. It's value is 128.17:30:33.3444555. Then as the result of using the expression
GetTimeSpanMinutes({$TimeSpan})
is 30.

ПолучитьСекундыИнтервала

Returns a time interval (in seconds) as a string (is a Russian counterpart of the GetTimeSpanSeconds).

 

GetTimeSpanSeconds

Returns a time interval (in seconds) as a string.

Function parameters: 
[0]*: A time interval (TimeSpan) 

Result: the interval seconds as a string.

Example: assume a TimeSpan variable of the Time Span type. It's value is 128.17:30:33.3444555. Then as the result of using the expression
GetTimeSpanSeconds({$TimeSpan})
is 33.

Formatting functions

DateTimeFormat

Allows displaying the date and time in the specified format.

Function parameters: 
[0]*: Date/time (DateTime) 
[1]: Display format (string) 

Result: the value of the current DateTime object converted to an equivalent representation of the specified format.

Example: 
Expression {DateTimeFormat({$DataTime}; ‘yy-MM-dd’)} will return 17-05-18 
Expression {DateTimeFormat({$DataTime}; ‘G’)} will return 18.05.2017 1:30:00

NumberFormat

Returns a number in the specified format.

Function parameters: 
[0]*: Number (all number types, except byte) 
[1]: One of standard or custom display formats (string) 
[1]: The number of decimal places (all number types, except byte) 

Note: if a floating point number is passed as the second parameter, then the number of decimal places will equal the integer part of the number with rounding up.

Result: value converted to an equivalent string representation of the specified format.

Example: for the expression
{NumberFormat(2345.6789;3)} the result is 2345,679 
for {NumberFormat(0.6789;’G’)}, result - 0,6789
for {NumberFormat(0.6789;’P’)}, result - 67,89%.

MoneyFormat

Allows displaying a number in a money format. Only for Russian money.

Function parameters:
[0]*: A number (all number types, except byte)

[1]: The number of decimal places (all number types, except byte)

Result: the number converted to a money format. if a floating point number is passed as the second parameter, then the number of decimal places will equal the integer part of the number with rounding up.

Example:
{MoneyFormat(23451234.6789;2)}

Functions for generating notifications

GetEntityUrl

Allows getting a link to an object page.

Function parameters: 
[0]*: Объект (IEntity) 

Result: a string that contains a link to an object page.

Example: assume a Task variable of the Task Base Class type, with ID - 603. To generate a link to the object page, use the expression: 
{GetEntityUrl({$Task})} 
Result: "/Tasks/Task/Execute/603".

Functions for working with users

GetUserShortName

Allows getting an abbreviated user name (initials).

Function parameters: 
[0]*: A user (IUser) 

Result: user's initials instead of the full name (e.g. J.K. Simmons).

Example: assume an Initiator variable of the User type. To get an abbreviation, use the expression: 
{GetUserShortName({$Initiator})}

Functions for working with time report entries

WorkTimeToFormatString

Returns a formatted value of business time in days, hours and minutes.

Function parameters: 
[0]*: Business time interval (WorkTime)

Result: formatted business time interval in days, hours and minutes. 

Example: assume a WorkLogItem variable of the Time Report Item type. To return the value of time worked (FactWorkTime) use the expression: 
{WorkTimeToFormatString({$WorkLogItem.FactWorkTime})}

LoadEntityByWorkLogItem

Allows loading an object.

Function parameters: 
[0]*: Time report item (IWorkLogItem)

Result: the specified object will be loaded.

Example: assume a WorkLogItem variable of the Time Report Item type. As a time report object a Task is selected. To load the task via WorkLogItem, use the expression:
{LoadEntityByWorkLogItem({$WorkLogItem})}

GetEntityDisplayNameByWorkLogItem

Returns the object display name.

Function parameters: 
[0]*: Time report item (IWorkLogItem) 

Result: the string that contains the object display name.

Example: assume a WorkLogItem variable of the Time Report Item type. As a time report object a Task is selected. To load the task via WorkLogItem, use the expression: 
{GetEntityDisplayNameByWorkLogItem({$WorkLogItem})}

Functions for working with tasks

GetInformToExceptMembers

Generates the list of users from the co-executors of the first task, who are not co-executors of the second.

Function parameters: 
[0]*: First task (ITaskBase) 
[1]*: Second task (ITaskBase) 

Result: the list of users from the co-executors of the first task, who are not co-executors of the second.

Example: assume the Task1 and Task2 variables of the ITaskBase type. The co-executors of the Task1 are Peter Proul and Kevin Mitchel, and the co-executors of the Task2 are Peter Proul and Dan Stenpyke. To get the co-executors of the Task1 who are not the co-executors of the Task2, use the expression:
{GetInformToExceptMembers({$Task1};{$Task2})}

Result: Keving Mitchel.

Or vice versa:
{GetInformToExceptMembers({$Task2};{$Task1})}
Result: Dan Stenpyke.

You can find more information about templates in these articles:

  1. Generate a file from a template
  2. Display of a Block variable in a document template
  3. Double generation by a template