Bitrix24Care

Using expressions in activity parameters

In the system, you can calculate the values of expressions in action parameters. For example, add, multiply, calculate percentages, and more.

To perform calculations, you have to put a = sign in the field before the operations.

Example: =6^2 + {=Document:PROPERTY_NUM}/2 or =if({Document:ID}=5, "text1", "text2").

You can use several different calculations in each field at once. If you want not only to make a calculation, but also to get additional data (variable values, text), two options are available:

  • You can place computable values in the text by putting the calculation in a {{=...}}.

    Example:You need to execute the documents before {{=DateAdd({=Document:CREATED}, '5d')}}.

  • You can use the concatenation operator (&) and write the text in quotes(").

    Example: ="Reply:" & (1+3) or ="Author: " & {=Document:CREATED_BY} & ", " & "Deadline: " & Dateadd({=Document:DATE_CREATE}, "1d")

The syntax of the symbolic operators is similar to that of the corresponding php-functions.

Operators

You can use various operators and functions to calculate the values of expressions in action parameters.

List of available operators

Operator Description
+ Add values.
- Subtracts values.
* Multiplies values.
/ Divide values.
= Equal.
<> Not equal.
< Less than.
> More than.
<= Less than or equal.
>= More than or equal.
() Procedure.
& Concatenation operator, which returns a string representing the union of the left and right arguments.
^ Exponentiation.
% Percentage.
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

You can use functions in the actions when designing a business process. You can select them from a list. To do this, write = in the field to open the list.

Function list with examples

Function Description
abs Number modulus calculation.
dateadd

It adds specified number of years, months, days, hours, minutes and seconds to a specified date.

Syntax: =dateadd([start_date], [what_to_add])

Writing variants and examples

y, year, years, m, month, months, d, day, days, h, hour, hours, min, minute, minutes, s, second, seconds.

You can use upper or lower case when writing.

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

If the number of time units needed to add is contained in a field, you should use the concatenation operator&.

Example: =DateAdd({=Document:DATE_CREATE}, {=Variable:WHAT2ADD} & "y 10h")

datediff

It allows to calculate the difference between dates.

Syntax: =datediff([first date], [second date], [how to output the difference])

The difference can be output in different units, depending on the solving tasks.

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

The function outputs the date in the specified format and works similarly to the function Date in PHP.

Syntax - date ('output format', {desired date})

WorkDateAdd

Adds the specified number of work days, hours and minutes to the specified date.

Syntax: =WorkDateAdd([start_date], [what_to_add]).

Writing options and examples

d, day, days, h, hour, hours, i, min, minute, minutes. It is allowed to write both in upper and lower case.

Example: =WorkDateAdd({=Template:Parameter1}, "2d") - the parameter contains a date 28.04.2016.

Result - 02.05.2016 09:00:00, because 30.04 and 1.05 are weekends, they will be missed. 09:00:00 - start of the work day.

You can configure the list of weekends and the beginning of the work day on the Settings Page.

AddWorkDays The function adds N number of work days to the specified date.

Syntax: =addworkdays([the date to which the days will be added], [the number of work days to be added]).

Examples: {{=addworkdays('07.03.2016', 1)}} - result: 09.03.2016 00:00:00, because March 8 is a day off in the settings of the site.

{{=addworkdays('05.02.2016 16:14:00', 1)}} - result: because 05.02.2016 is Friday, the result is 08.02.2016 16:14:00 is Monday.

isWorkDay Checks if the date is a work day (according to the Calendar).

Syntax: =if(isWorkDay([verifiable date]), [message if the date is a work day], [message, if it is not]).

Example: {{=if(isWorkDay({=Template:Parameter1}), 'Yes', 'No')}} - the parameter contains the date 28.04.2016. Result is Yes, because it is a work day.
isWorkTime It is similar to the isWorkDay function, but for the Date/Time data types.

Syntax: =if(isWorkDay([date verified with time]), [message if the date and time are working], [message, if it is not]).

Example:{{=if(isWorkTime({=Template:Parameter1}), 'Yes', 'No')}} - the parameter contains the date and time 27.04.2016 15:00:00.

Result is Yes, because it is work time.

toUserDate The function set any time to the time of the employee (taking into account a time zone).

toUserDate(user,date=now)

Parameters:
  • user - the user to whose time the time of the business process should be set.
  • date - start date, default - current time.
GetUserDateOffset The function returns the value of the user's time zone shift in seconds (relative to the server time).

GetUserDateOffset(user)

Parameter:
  • user - user, relative to whose time the value is needed.
if Conditional operator.

Syntax: =if([condition],[result_if_it_meets_the_condition],[result_if_it_does_not_meet_the_condition])

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

When comparing variable values, it is also possible to compare variables with different data types. However, the compared variable values should match the type conversion table (it is available in this article).

intval Returns an integer value of the variable.
Example:=intval("234j4hv5jhv43v53jk4vt5hj4") returns 234.
floatval Returns a number (with a floating point).
numberformat Forms the number with a group division.
min It returns lowest value.
max It returns highest number.
rand It returns a random number.

Syntax: =rand([minimum value],[maximum value]).

Only the minimum value is required. If you don't want to limit the upper value, you can omit the second parameter, for example =rand(17).

Example: =rand(0,10) - select a number from 0 to 10.

round rounds the number.

Syntax: =round([that is rounded up],[number of decimal places])

Example:

  • =round(10/3,2) - we get 3.33.
  • =round(5/2) - we get 3.

ceil Rounds the fraction up.
Example: =ceil(5.5) we get 6.
floor Rounds the fraction down.
Example: =floor(5.5) we get 5.
substr It returns a substring of a specified length, starting from a specified character. This function is similar to the existing one in php. You can read more about its features here.

Syntax: substr([input string], [from which character of the original string the article to be returned starts], [how long the string will be]).

Keep in mind that the string starts with the character number 0. For example, in the string 'abcdef', in 0 position, there is the character 'a', in 2 position, there is the character 'c', etc.

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

If the syntax of the expression is wrong, it will be displayed as a text.

strpos It returns the position of the first occurrence of a substring.
strlen It returns the line length.
implode Combines multiple values into a string. It is useful when it is needed to output multiple variable values to the text with a non-standard delimiter (standard delimiter is just a comma). The analog of implode in PHP. It returns a string containing a string representation of all the array elements in the specified order, with glue between elements.
implode(glue,pieces)

Parameters:

  • glue - by default, it is equal to an empty string
  • pieces -an array of merged strings.
explode The function splits a string with a delimiter. It is useful when you want to split a string and assign the parts as the value of a plural variable. The analog is explode in PHP. It returns an array of strings obtained by splitting a str string using delimiter.
explode( delimiter, str)

Parameters:

  • delimiter
  • str - split string.
randstring It returns a random string.
merge It allows to merge arrays.

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

Example: = merge({=Document:FILES}, {=Variable:file}).
urlencode URL-string coding.
strtolower It converts the string into lowercase.
strtoupper It converts the string into uppercase.
ucwords It converts the string into upper case, the first character of each new word in the string.
firstvalue It returns the first value of the multiple field.
swirl It moves the first value of the multiple field to the end. The multiple field is input, the output is values shifted by one step on the left, i.e. the first value is at the end. The shift is always by one step.
shuffle It shuffles the values of a multiple field. It is analogous to the shuffle in PHP. A multiple field is input, the output is a shuffled value of that multiple field.
Example:

Let's consider shuffle, firstvalue and swirl functionson in a business process. With this business process, you can set a task for an employee from the list and add another user as a co-executor.

The business process uses the Users multiple variable, which stores a list of employees.

First, we shuffle the list of users with shuffle and take the first one with firstvalue. That will be our responsible one.

Then we move this list with swirl and take the first one with firstvalue. That will be our co-executor.

Fill in the parameters of the problem.

After running the business process, any employee will be added to the task as a responsible person and co-executor.


Recommended articles::
Was this information helpful?
Integration specialist assistance
That's not what I'm looking for
Complicated and incomprehensible text
The information is outdated
It's too short. I need more information
I don't like the way this tool works
Go to Bitrix24
Don't have an account? Create for free
Related articles
Dateadd function Addworkdays function Configure workflow template parameters Import and export workflows templates