Views: 76
Last Modified: 13.10.2021

You can use the following functions and operators when calculating expression values in action parameters.

  Operators

The following operators are available:

OperatorDescription
+ Addition.
- Subtraction.
* Multiplication.
/ Division.
= Equal.
<> Not equal.
< Less.
> More.
<= Less or equal.
>= More or equal.
() Sequence of actions.
& Operator for concatenation that returns string, consisting of appendage of left and right arguments.
^ Powering.
% Calculation of interest.
true True.
false False.
and Logical operator AND.
or Logical operator OR.

Example: =if(or({=Variable:aaa}>2, {=Variable:bbb}<10), "yes", "no")
not Negation.

  Calculation functions

Functions can be used when designing workflows. They can be added via two methods:

  • Select from list. Write the character = that opens the list:

  • Enter manually.

List of functions with examples:


FunctionDescription
abs Calculating module abs.
dateadd Adds a specified number of days, months, years, hours, minutes and seconds to the specified date.

Syntax: =dateadd([start_date], [added_date]);


Examples: =Dateadd({=Document:DATE_CREATE}, "-2d"), =Dateadd({=Document:DATE_CREATE}, "2 days 3 minutes").

In case, the number of units of time required to be added is contained in the fields, variable and etc., user the concatenation operator &.

For example: =DateAdd({=Document:DATE_CREATE}, {=Variable:WHAT2ADD} & "y 10h")
datediff Allows calculate the difference between tow dates.

Syntax:
=datediff([first_date], [second date], [how to input the difference]);

Allows printing different time objects, depending on target objectives.

Examples:
=datediff({=Variable:Variable1}, {=Variable:Variable2},'%m month, %d days')

date For correct date formatting The best option for executing this task. Using string functions types substr and strpos is not recommended. . Operates in the same manner as Date function in PHP.
AddWorkDays Function adds N workdays to the specified date.

Syntax:
=addworkdays([date with added days], [number of added workdays]).

Examples:

  • {{=addworkdays('03.07.2016', 1)}} - result: 09.03.2016 00:00:00, because site settings deem 4 July as a holiday.
  • {{=addworkdays('05.02.2016 16:14:00', 1)}} - result: because 05.02.2016 - Friday, the result: 08.02.2016 16:14:00 - Monday.

isWorkDay Checks, if date is a workday (as per Calendar).

Syntax:
=if(isWorkDay([checked_date]), [message, if date is a workday], [message, if false]).

Parameter [user] is optional. It can indicate user, which work time must be considered. Available from bizproc module version 19.0.0.

Example:
{{=if(isWorkDay({=Template:Parameter1}), 'Yes', 'No')}} - parameter contains date 28.04.2016. Result - Yes, because this day is a workday.

isWorkTime Similar to the function isWorkDay, but for new data types - Date/Time.

Syntax:
=if(isWorkDay([checked date with time]), [message if date with time is during worktime], [message if not during worktime]).

Parameter [user] is optional. It can indicate user, which work time must be considered. Available from bizproc module version 19.0.0.

Example:
{{=if(isWorkTime({=Template:Parameter1}), 'Yes', 'No')}} - parameter contains date with time 27.04.2016 15:00:00. Result - Yes, because it's a worktime.

toUserDate Function coverts any time format into employee time format (with account of hour zone).
toUserDate(
   user,
   date=now
)
Parameters
  • user - user. Workflow time format must be converted to this user time format;
  • date - start date, current time - by default.
GetUserDateOffset Function returns hour zone time offset in seconds (to server time).
GetUserDateOffset(
   user
)
Parameters:
  • user - user time value.
if Condition.

Syntax:
=if([condition], [result_on_success], [result_on_failure]);

Example:
=if ({=Variable:Variable1_printable}>0, "yes", "no")

Comparing variables also allows comparing variables with different data type. However, comparable variables must match to type conversion table.

intval Returns variable integer;

Example:
=intval("234j4hv5jhv43v53jk4vt5hj4") returns 234.
floatval Returns variable (with float value).
numberformat Formats a number with groupings.
min Returns lowest value.
max Returns highest value.
rand Returns random integer.
round Rounds up a number.
ceil Rounds the fraction up.
floor Rounds the fraction down.
substr Returns the portion of string specified by the offset and length parameters. This function is similar to the existing substr in PHP.

Syntax:
substr([input string], [depending on starting input string character], [string length])

Be advised that string starts from "0" character. For example, the string 'abcdef', position 0 contains character 'a', in position 2 - character 'c', and others.

Example:
{{=substr("0123456789", 3, 4)}} returns 3456.

Attention! When expression syntax is incorrect, shows as text.
strpos Returns position of first occurrence of a substring in a string .
strlen Returns string length.
Implode Merges multiple values into string. Useful when text multiple variables must be printed in the text by non-standard separator (standard: simple comma). Similar to implode in PHP.
Returns string containing string representation of all array elements in a specified order, with value glue between each element.
Implode(
   glue,
   pieces
) 
Parameters:
  • glue - equals to empty string by default;
  • pieces - array with merged strings.
explode Function parses string using separator. It is useful, when string must be parsed and create multiple variable. Similar to explode in PHP.
Returns array with strings, retrieved by splitting the string str using delimiter as a separator.
explode(
   delimiter,
   str)
Parameters:
  • delimiter - separator;
  • str - string for splitting.
randstring Returns random string.
merge Allows to merge arrays.

Syntax:
= merge({=array_1}, {=array_2});

Example:
= merge({=Document:FILES}, {=Variable:file}).

urlencode string URL encoding.


0


Courses developed by Bitrix24