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
|
Number modulus calculation. |
dateadd
|
It adds specified number of years, months, days, hours, minutes and seconds to a specified date.
Syntax: Writing variants and examples
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: 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 - |
WorkDateAdd
|
Adds the specified number of work days, hours and minutes to the specified date.
Syntax: Writing options and examples
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: 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.
|
isWorkDay
|
Checks if the date is a work day (according to the Calendar).
Syntax: 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: 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:
|
GetUserDateOffset
|
The function returns the value of the user's time zone shift in seconds (relative to the server time).
GetUserDateOffset(user)Parameter:
|
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
|
Forms the number with a group division. |
min
|
It returns lowest value. |
max
|
It returns highest number. |
rand
|
It 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, for example Example:
=rand(0,10) - select a number from 0 to 10.
|
round
|
rounds the number.
Syntax: Example:
|
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: 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:
|
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:
|
randstring
|
It returns a random string. |
merge
|
It allows to merge arrays.
Syntax: 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 The business process uses the Users multiple variable, which stores a list of employees.
First, we shuffle the list of users 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::