Bitrix24 Helpdesk

Bitrix24 has a new interface. The images in the articles might differ from the current account design. We will update them soon.

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 Returns the absolute value of a number.
PHP abs() function
dateadd

Adds a specified number of years, months, days, hours, minutes, and seconds to a given date.

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

Writing options and examples

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

You can use both 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

Calculate the difference between two dates.

Syntax: =datediff([first_date], [second_date], [format])

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

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

Returns the specified date in a given format, similar to the PHP date() function.

Syntax: =date('format', [date])

WorkDateAdd

Adds a specified number of working days, hours, and minutes to a given date.

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

Writing options and examples

Accepted time units: d, day, days, h, hour, hours, i, min, minute, minutes.

You can use both upper or lower case when writing.

Example: =WorkDateAdd({=Template:Parameter1}, "2d")
If Parameter1 is 28.04.2016, and 30.04 and 01.05 are weekends, the result will be 02.05.2016 09:00:00.

  • 02.05.2016 is the next working day after skipping the weekend.
  • 09:00:00 is the default start time of the workday.

You can configure weekends and working hours in the Bitrix24 Settings section.

AddWorkDays Adds a specified number of working days to a given date.

Syntax: =addworkdays([date], [number_of_workdays])

Examples: {{=addworkdays("03.07.2024", 1)}} returns 05.03.2024 00:00:00 since July 4 is a day off in the account settings.

{{=addworkdays("05.02.2016 16:14:00", 1)}} returns 08.02.2016 16:14:00 since 05.02.2016 is Friday and 08.02.2016 is Monday.

isWorkDay Checks if a given date is a working day according to the calendar settings.

Syntax: =if(isWorkDay([date]), [value_if_true], [value_if_false])

Example: {{=if(isWorkDay({=Template:Parameter1}), "Yes", "No")}}
If Parameter1 is 28.04.2016, the result will be Yes because April 28 is a working day.
isWorkTime Similar to isWorkDay, but checks if the date and time fall within working hours.

Syntax: =if(isWorkDay([datetime]), [value_if_true], [value_if_false]).

Example:{{=if(isWorkTime({=Template:Parameter1}), "Yes", "No")}}
If Parameter1 is 27.04.2016 15:00:00, the result will be Yes because that time falls within working hours.
toUserDate Converts a given date and time to the user's local time, taking into account their time zone.

toUserDate(user,date=now)

Parameters:
  • user — The user whose time zone should be applied.
  • date — The date and time to convert. Defaults to the current server time if not specified.
GetUserDateOffset Returns the value of the user's time zone shift in seconds, relative to server time.

GetUserDateOffset(user)

Parameter:
  • user — The user for whom the time zone offset is calculated.
getdocumenturl

Returns a link to the current document where the workflow is running.

Syntax: {{=getdocumenturl [link_format], [full_link]}}

Parameters:

Link format:

  • 'bb' — formats the link as BBCode, e.g., [url=link]Document Title[/url]
  • 'html' — formats the link as HTML, e.g., <a href="link">Link Text</a>

Full link: If true, includes the full site domain in the link, e.g., https://example.com/...

Examples:

1. Link formatted as BBCode:
{{=getdocumenturl('bb')}}

2. Full link with domain, formatted as HTML:
{{=getdocumenturl('html', true())}}

if Conditional operator.

Syntax: =if([condition],[result_if_true],[result_if_false])

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

Formats numbers a number to improve readability by:

  • Adding spaces between thousands, e.g., 1 000 000 instead of 1000000
  • Using a comma as the decimal separator, e.g., 123,45 instead of 123.45

Example: {{=numberformat(2500000.75; 2; ","; " ")}} returns 2 500 000,75.

min Returns the lowest value.
max Returns the highest number.
rand 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, like =rand(17).

Example: =rand(0,10) returns a random value between 0 and 10.
round Rounds the number.

Syntax: =round([value_to_round],[decimal_places])

Examples:

  • =round(10/3,2) returns the value 3.33
  • =round(5/2) returns the value 3

ceil Rounds the fraction up.
Example: =ceil(5.5) returns 6.
floor Rounds the fraction down.
Example: =floor(5.5) returns 5.
substr Returns a substring of a specified length, starting from a specified character. This function is similar to the PHP substr() function.

Syntax: substr([input_string], [start_position], [length]).

Note: String indexing starts at 0. For example, in the string 'abcdef', position 0 is 'a', position 2 is 'c', etc.

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

If the syntax of the expression is wrong, it will be displayed as text.
strpos Returns the position of the first occurrence of a substring.
strlen 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 (the standard delimiter is just a comma). This function is equivalent to PHP's implode(). 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 — The string inserted between elements. If not specified, an empty string is used.
  • pieces — An array of merged strings.
explode 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. This function is equivalent to PHP's explode(). It returns an array of strings obtained by splitting a str string using delimiter.
explode( delimiter, str)

Parameters:

  • delimiter — The character or substring used to split the string.
  • str — The input string to be split.
randstring Returns a random string.
merge Merges arrays.

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

Example: =merge({=Document:FILES}, {=Variable:file})
urlencode URL-string coding.
strtolower Converts the string into lowercase.
strtoupper Converts the string into uppercase.
ucwords Converts the string into uppercase, the first character of each new word in the string.
firstvalue Returns the first value of the multiple field.
swirl 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 Randomly shuffles the values of a multiple field. This function is equivalent to PHP's shuffle(). A multiple field is input; the output is a shuffled value of that multiple field.
Example

Consider shuffle, firstvalue, and swirl functions in a workflow to randomly assign a task to one employee and select another as a participant.

The workflow uses a multiple variable called Users, which stores a list of employees.

  1. First, the list is randomized using the shuffle function.

  2. The firstvalue function is then applied to select the first user from the shuffled list. This user becomes the assignee.

  3. Next, the list is reordered using the swirl function, and firstvalue is used again to select another user. This one becomes the participant.

Also, fill in the task parameters.

After running the workflow, it will assign the task to one randomly selected user and add another as a participant

settime

Adds a specific time to a date.

Syntax: {{=settime(Date, Hours, Minutes)}}

Examples:

  • Set a specific time:
    {{=settime(03.12.2023, 15, 55)}} returns 03.12.2023 15:55:00.

  • Automatic time correction:
    {{=settime(03.12.2023, 21, 79)}} returns 03.12.2023 22:19:00 (79 minutes becomes 1 hour and 19 minutes).

trim

Removes leading and trailing spaces from a text string.

Syntax: {{=trim([string])}}

Example: If Variable1 contains " 123 " (with spaces), then:
{{=trim(Variable1)}} returns "123" (without spaces).


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
Get your Bitrix24 set up by local professionals
FIND BITRIX24 PARTNER NEAR ME
implementation_helper_man
Go to Bitrix24
Don't have an account? Create for free
Related articles
Import and export workflows templates Dateadd function Select workflow type Addworkdays function Configure workflow template parameters