Views: 3895 (Data available since 06.02.2017)

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 http://www.php.net/manual/en/function.substr.php for details.

Attention! If an expression has an error, it will not be evaluated and will be displayed as text.



Courses developed by «Bitrix», Inc.