Views: 4399
Last Modified: 18.08.2021

The system can calculate expression values in action parameters. For example, store, multiply, calculate percentages and etc.

  Calculating expressions

To execute calculations, set character = in the field in front of operations.

Example: =6^2 + {=Document:PROPERTY_NUM}/2 или =if({Document:ID}=5, "text1", "text2").

Each field can use several calculations simultaneously.

If you want to not only perform calculation, but also print additional data (variable values, text), there are two options available:

  • Calculated values can be simply placed in text, by inserting into the structure {{=...}}.
    Example:You need to issue documents before {{=DateAdd({=Document:CREATED}, '5d')}}:

  • Or use concatenation operator (&), and put text in quotes (").
    Example : ="Response:" & (1+3) or ="Author: " & {=Document:CREATED_BY} & ", " & "Deadline: " & Dateadd({=Document:DATE_CREATE}, "1d")
Note: symbolic operator syntax is similar to the syntax of corresponding PHP functions.

  Recommendations

Be advised, when using curly brackets {{...}} or automatic substitution, by selecting functions from list. Incorrect bracket positioning - is a frequent mistake when handling expression calculations in workflows.

Correct record  

=datediff({{Element created on}},{{Element Last Modified On}},"%a") * 2 if no extra text present
or
{{=datediff({{Element created on}},{{Element Last Modified On}},"%a") * 2}}, if extra text is required.

Incorrect record  

={{=datediff({{Element created on}},{{Element Last Modified On}},"%a")}} * 2
или
{{={{=datediff({Element created on}},{{Element Last Modified On}},"%a")}} * 2}}

Another convenient method is to move calculations into a variable Variables are used for temporary data storage, necessary for executable process. Variable values are stored for the duration of workflow. After it's finalized, the data is erased. . Example of expression above shows how to move datediff function calculation into the variable (action Set variables This action allows to modify variables, specified in template settings. ). Then, multiply the same variable by 2. Get the record: ={=Variable:Variable2}*2, where Variable2 stores function calculation values: =datediff({{Element created on}},{{Element Last Modified On}},"%a").

0


Courses developed by Bitrix24