Skip to main content

12.03 Using operators in a node

As an example of configuring a node using operators, let's create a scenario in which the input parameters are certain values, and the outcome of the scenario will be the transformation of these values using operators.

To make the scenario work successfully, you need to add 3 nodes:

  • (1)Trigger on Webhook node with a URL to which a POST request is sent, containing the value ValueWH;
  • (2) SetVariables node that adds the value ValueSV to the scenario;
  • (3)Webhook Response node that returns the transformed value using operators;
  • (4) Configure the conditions for responding to the execution of the scenario in the Body field of the Webhook Response node.

In scenarios that require processing numerical expressions, operators such as comparison operators (less than, less than or equal to, not equal to, AND, OR, etc.), mathematical operators (addition, subtraction, etc.), and some functions (if, (), not, etc.) are commonly used.

Example 1:
  • Input data: ValueWH = 15; ValueSV = 40;
  • Expression with operators:
If ValueWH is less than 30, then the answer is the difference between ValueSV and ValueWH; otherwise, it's the sum of ValueSV and ValueWH;
  • Answer: 25.

If it is necessary to process string expressions, most often comparison operators (AND, OR, etc.) and functions (if, (), starts with, ends with, string length, etc.) are used.

Example 2:
  • Input data: ValueWH = May; ValueSV = October;
  • Expression with operators:

If the length of the string ValueWH is less than 4 OR the string ValueSV ends with "er", then the answer is the string ValueSV in uppercase; otherwise, it's ValueWH.

  • Answer: OCTOBER
Example 3:
  • Input data: ValueWH = May05; ValueSV = October;
  • Expression with operators:
If the presence of "ay" in ValueSV is false AND ValueWH contains digits, then the answer is the string ValueWH; otherwise, it's ValueSV;
  • Answer: May05.
tip

The result of executing an expression can depend on the type of fields over which operations are performed. For example, the '+' operator performs concatenation of text fields and addition of numeric fields

tip

Some operators work only with text values or only with numeric values. For instance, the 'length' operator counts the number of characters in a text string.