Views: 7147
Last Modified: 24.01.2019
To deliver maximum flexibility, the activity parameters allow the use of special expressions whose values are calculated at run time. To specify that a parameter value is an expression, use the Excel-like notation – that is, start the value with an "equals" sign: =
. In other words: an expression is anything that is prepended with an equals sign.
Examples:
=6^2 + {=Document:PROPERTY_NUM}/2
=if({Document:ID}=5, "text1", "text2")
A parameter can use only one expression. To use multiple expressions in a parameter, use the concatenation operator (&
), and enclose text in the expressions in double quotes ("
) as needed.
Examples:
="Reply:" & (1+3)
="Author: " & {=Document:CREATED_BY} & ", " & "Deadline: " & Dateadd({=Document:DATE_CREATE}, "1d")
As you will see below, the syntax of operators and functions in expressions is largely based on the syntax of those in PHP.
The following operators and functions are possible.
- + - adds two values;
- - - subtracts the second value from the first one;
- * - multiplies two values;
- / - divides the first value by the second one;
- = - assigns (i.e. returns) the expression result;
- <> - not equal;
- < - less than;
- > - more than;
- <= - less than or equal;
- >= - more than or equal;
- () - round brackets;
- & - concatenation operator. Return a new string which is the left string plus the right string;
- ^ - power;
- % - percent;
- true - Boolean true;
- false - Boolean false;
- and - Boolean AND;
- or - Boolean OR;
- not - Boolean NOT;
- min - returns the minimum of the two values;
- abs - returns the absolute value of an argument;
- dateadd - adds the time span passed as the second argument to the date specified as the first argument.
Syntax:
=dateadd([initial date], [time span])
The following units are possible in the time span: y
, year
, years
, m
, month
, months
, d
, day
, days
, h
, hour
, hours
, i
, min
, minute
, minutes
, s
, second
, seconds
. The units are case insensitive.
Examples:
=Dateadd({=Document:DATE_CREATE}, "-2d")
=Dateadd({=Document:DATE_CREATE}, "2 days 3 minutes")
- datediff - Returns the difference between two dates.
Syntax:
=datediff([date1], [date2], [difference_display_format])
;
The difference can be displayed in various units.
Example: =datediff({=Variable:Variable1}, {=Variable:Variable2},'%m month, %d days')
- if - specifies a condition;
Syntax:
=if([condition], [expression if true], [expression if false])
Example:
=if ({=Variable:Variable1_printable}>0, "yes", "no")
- intval - returns the integer of the value passed as the parameter;
Example:
=intval("234j4hv5jhv43v53jk4vt5hj4")
returns 234 because the value starts with this number, and the character immediately following the "4" is not a number.
- substr - returns the portion of a string as specified by the last two parameters. See here for details.
Attention! If an expression has an error, it will not be evaluated and will be displayed as text.
merge
- Allows to merge arrays.
Syntax: = merge({=array_1}, {=array_2})
;
Example: = merge({=Document:FILES}, {=Variable:file})
.
AddWorkDays
- this function adds N workdays to the specified date.
Syntax: =addworkdays([date to which says are added], [number of added workdays])
.
Example:
{{=addworkdays('07.03.2016', 1)}}
- the result: 09.03.2016 00:00:00
, because site settings specify 8 March as weekend day.
{{=addworkdays('05.02.2016 16:14:00', 1)}}
- result: because 05.02.2016 - Friday, the result : 08.02.2016 16:14:00
- Monday.
isWorkDay
- verifies, if the a day is a workday (based on Calendar).
Syntax: =if(isWorkDay([verified date]), [the message, if the date is a workday], [message if it is not])
.
Example:
{{=if(isWorkDay({=Template:Parameter1}), 'Yes', 'No')}}
- the parameter contains the date 28.04.2016
. Result - Yes, because this date is a workday.
isWorkTime
- similar to function isWorkDay
, but for data types Date/Time.
Syntax: =if(isWorkDay([verified date/time]), [message if the date/time is a workday], [message if they are not])
.
Example:
{{=if(isWorkTime({=Template:Parameter1}), 'Yes', 'No')}}
- the parameter contains the date with time 27.04.2016 15:00:00
. Result - Yes, because it is a worktime.
WorkDateAdd
- adds the specified number of workdays, hours and minutes to the specified date.
Syntax: =WorkDateAdd([start_date], [what_is_added])
.
Spelling options: d, day, days, h, hour, hours, i, min, minute, minutes
. Upper and lower case is allowed.
Example:
=WorkDateAdd({=Template:Parameter1}, "2d")
- parameter contains the date 28.04.2016
. Result - 02.05.2016 09:00:00, because 30.04 and 1.05 - are weekends, so they are skipped. 09:00:00 - workday start. Weekends and workday start can be configured in the Bitrix24 account settings.