Syntax rules for expressions

An expression must be written in the correct syntax.

Syntax rules:

  • Numbers, dates, string values, operands, object fields, operation names, variables, and functions are allowed.
  • String values must be enclosed in single or double quotation marks. For variables, such as [$END_USER$], string values enclosed in double quotation marks are resolved, whereas those enclosed in single quote marks are kept as-is.
  • Spaces are not a syntax error between operands in an entire expression, for example, between operands like + and == and in if/then/else/endif statements. Extra spaces and no spaces are allowed.
  • Carriage returns (new lines) are allowed.
  • Values within [$$] are case-sensitive. This means that the special variable, [$END_USER$], must be written in uppercase in an expression.
  • Values outside of [$$] are case-insensitive. This means that the names of functions are case-insensitive, for example, sum, Sum, and SUM are all valid.
  • String values that are enclosed in single or double quotation marks are case-sensitive. For example, for an if/then/else/endif statement that contains a condition like if “test” == “TEST”, the result is false.
  • Operation names must be enclosed in [$$] and be given correctly in both spelling and case. This means that an operation that is named Get Due Date is written in subsequent operation expressions as [$Get Due Date$].
  • Object field names must be given in the following format: [$field group:field name$]. The field group and field name must be given correctly in both spelling and case.
  • Object field names that reference parent, child, and preference objects must be given in the correct format. The object type, field group, and field names must be given correctly in both spelling and case. For example, for [$Child:object type/field group:field name$], the spelling and case of all names must be correct and the C in Child must be capitalized.

    For more information about object fields, see Object fields.

  • Add system variables, if needed. For more information, see System variables.
  • Apply functions, if needed. Functions must be correct for the data type. For more information, see:
  • Arguments for functions must be enclosed in parentheses.
  • Starting and ending parentheses must match.
  • Functions that require no arguments must have empty parentheses. For example, the tomorrow function is written as tomorrow().
  • A function can contain another function as an argument.
  • Use if/then/else/endif statements, if needed. For more information, see If/then/else/endif statements.
  • Add comments (optional). Comments must be given in the correct format.

Operands for string values

The + operand can be used on string values.

Table 1. Operands for string values
Operand Description Expression Result
+ Concatenates two or more text strings.

A string value can be enclosed in either single or double quotation marks.

"abc" + "def"

[$S1$] + [$S2$], where the operations contain the string values abc and def

[$S1$] + "def"

[$field group:field name$] + "def", where the field contains string value abc

abcdef

Operands for numerical values

The following operands can be used for integer, decimal, or currency values. Add and subtract can be used for dates. If an argument is a list, the operand is applied to all items in the list.

Table 2. Operands for numerical values
Operand Description Expression Result
+ Add 100.00 + 5 105.00
   

[$N1$] + [$N2$], where N1 contains 100.00 and N2 contains 5

105.00
   

[$N1$] + 5

105.00
   

[$field group:field name$] + 5, where the field contains 100.00

105.00
   

([$TODAY$] + 10), where today is May 18, 2020.

2020-05-28

- Subtract 100.00 - 5 95.00
   

[$field group:field name$] - 5, where the field contains the date 2020-06-06

2020-06-01

   

[$L1$] - 5, where L1 is a list of the following values: 100.00, 200.00, 300.00

95.00, 195.00, 295.00
* Multiply 100.00 * 5 500.00
/ Divide 100.00 / 5 20.00
( ) Set precedence

100.00 / (2 + 3)

20.00
   

10 * ( [$N1$] - 30.3 ), where N1 contains 100.00.

697.00

Syntax rules for comments

You can add two types of comments to an expression:

  • Paragraph comments

    Enclose the text in slash single or double asterisk, for example, /* text */ or /** text **/. Optionally begin each line within the block with an asterisk.

  • One-line comments
    • Begin a line with double slash, for example, // text
    • Place the comment text after an expression, for example, [$N1$] + 5 // Add 5 to N1

Both types of comments are included in the following example expression:

/**
 * KRI Indicator trend
 * Calculated by comparing two KRI Value Breach Status and setting to Not Determine, Steady, Worse, Better
 **/
//case 1: not enough KRI values
if count([$Child:KeyRiskIndicatorValue/OPSS-KRI-Shared:Breach Status/DescB:OPSS-KRIVAl:Value Date$]) < 2
// case 2: one of the recent has "Not Determine" 
elif (( at ([$Child:KeyRiskIndicatorValue/OPSS-KRI-Shared:Breach Status/DescB:OPSS-KRIVAl:Value Date$], 0)
   == ( at ([$Child:KeyRiskIndicatorValue/OPSS-KRI-Shared:Breach Status/DescB:OPSS-KRIVAl:Value Date$], 1)
// case 3: two recent ones have the same breach status