Jump to: navigation, search

Operator Precedence

If you use more than one operator in a formula, the order in which they are evaluated depends on their relative precedence (higher precedence operators are evaluated first). For example, multiplication (*) has a higher precedence than addition (+ ), so that the formula below evaluates to 14, not 20:

      <$2 + 3 * 4$>

You can use parentheses to override the default precedence. The formula below evaluates to 20:

      <$(2 + 3) * 4$>

For a complete list of operators and their relative precedence, see “Operator Precedence” in Chapter 3 of the eServices 8.1 Reference Manual.

Data Types

Operands of several different types may appear in formulas:

  • Number
  • String (text)
  • Date/time
  • Boolean (true/false)
  • Object (Contact, Interaction, and Agent)

Each data type behaves differently in formulas, and the operators have different meanings when you use them with different data types. For example, the + operator means “add” when used with numbers, but “concatenate” (paste together) when used with strings. This formula evaluates to Uncle Sam Wants You


      <$"Uncle Sam " + "Wants You"$>

In addition, some operators cannot be used with some data types at all. For example, you cannot use the multiplication (* ) operator on two strings.
All formulas, regardless of their final data type, are converted to strings before being merged into your standard response. This conversion follows a set of default rules that depend on the data type. For example, the default rules for numbers round them off to integers. This formula causes 2 to be inserted into your standard response, even though the real result is 2.25:

      <$9 / 4$>

You can use the Text function (see below) or format operator:) to override the default formatting. Either of the following formulas inserts 2.25 into your standard response:

      <$Text(9 / 4, "#.##")$>
      <$(9 / 4):"#.##"$>

For a detailed list of data types and how you can use them, see “Data Types” in the eServices 8.1 Reference Manual.

This page was last edited on December 19, 2013, at 15:43.
Comments or questions about this documentation? Contact us for support!