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.
=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")
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: Writing options and examples
Accepted time units: 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: 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: |
WorkDateAdd
|
Adds a specified number of working days, hours, and minutes to a given date.
Syntax: Writing options and examples
Accepted time units: 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 .
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: Examples:
{{=addworkdays("03.07.2024", 1)}} returns 05.03.2024 00:00:00 since July 4 is a day off in the account settings.
|
isWorkDay
|
Checks if a given date is a working day according to the calendar settings.
Syntax: 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: 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:
|
GetUserDateOffset
|
Returns the value of the user's time zone shift in seconds, relative to server time.
GetUserDateOffset(user)Parameter:
|
getdocumenturl
|
Returns a link to the current document where the workflow is running. Syntax:{{=getdocumenturl [link_format], [full_link]}}
Parameters: Link format:
Full link: If Examples:
1. Link formatted as BBCode: |
if
|
Conditional operator.
Syntax: 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:
Example: |
min
|
Returns the lowest value. |
max
|
Returns the highest number. |
rand
|
Returns a random number.
Syntax:
Only the minimum value is required. If you don't want to limit the upper value, you can omit the second parameter, like Example:
=rand(0,10) returns a random value between 0 and 10. |
round
|
Rounds the number.
Syntax: Examples:
|
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:
Note: String indexing starts at 0. For example, in the string 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:
|
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:
|
randstring
|
Returns a random string. |
merge
|
Merges arrays.
Syntax: 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 The workflow uses a multiple variable called Users, which stores a list of employees.
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: Examples:
|
trim
|
Removes leading and trailing spaces from a text string.
Syntax:
Example: If |