Loading
Salesforce now sends email only from verified domains. Read More
Business Rules Engine
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Operators and Functions in Expression Sets

          Operators and Functions in Expression Sets

          Formulas in expression sets support logical, comparison, mathematical, and string operators, and functions for dates and numbers.

          Required Editions

          Available in: Lightning Experience
          Available in: Enterprise, Unlimited, and Developer Editions for clouds that have Business Rules Engine enabled

          Supported Operators in Expression Sets

          Mathematical operators take precedence over comparison and string operators, which take precedence over logical operators. Within mathematical operators, ^ and % have the highest precedence, followed by * and /, then + and -. When precedences are equal, operations are performed from left to right. You can use parentheses, ( ), to explicitly specify precedence.

          Note
          Note Always include a space before and after an operator.
          Logical and Comparison
          Operator Description

          &&

          AND

          True if all the joined expressions are true. For example, A AND B returns true if both A and B are true.

          ||

          OR

          True if one of the joined expressions is true. For example, A AND B returns true if either A or B is true.
          = Assigns the value of the second expression to the first expression. For example, A = 2 sets the value of A to 2.

          ==

          Equals

          True if the values of the first and second expressions are equal. For example, 2 == 2 returns true.

          !=

          Not Equals

          True if the values of the first and second expressions aren’t equal. For example, 3 != 2 returns true.

          >

          Greater Than

          True if the first expression has a greater value than the second. For example, 3 > 2 returns true.

          >=

          Greater Than or Equal

          True if the first expression has a greater value than the second or if the values are equal. For example, both 3 >= 2 and 2 >= 2 return true.

          <

          Less Than

          True if the second expression has a greater value than the first. For example, 2 < 3 returns true.

          <=

          Less Than or Equal

          True if the second expression has a greater value than the first or if the values are equal. For example, both 2 <= 3 and 2 <= 2 return true.
          Is Null True if the value of a resource is null.
          Is Not Null True if the value of a resource isn’t null.
          If

          Returns a given value if true and another value if false.

          IF(logical_test, value_if_true, value_if_false)where logical_test is the expression you want evaluated; value_if_true is the value you want returned if the expression is true; value_if_false is the value you want returned if the expression is false.

          Make sure your value_if_true and value_if_false expressions are the same data type.

          • Example 1: Filtering a list of phones to show only Apple phones.

            IF(phones:brand == “Apple”, phones:name, null)

          • Example 2: Removing the dollar sign for calculations

            IF(SUBSTRING(price,0,1) == “$”, SUBSTRING(price,1),price)

          • Example 3: Setting a discount value for drivers under 25 if they are good students, and drivers over 25 if they refer two or more people.

            IF(DriverAge >= 25, IF(FriendsReferred >= 2, true, false), IF(GPA >= 3.0, true, false))

          Mathematical
          Operator Description
          + Adds two numbers.

          -

          Subtracts the second number from the first.
          * Multiplies two numbers.
          / Divides the first number by the second.
          % Returns the percentage of the first number specified by the second number. For example, 50 % 20 returns 10.
          ^ Returns the power of the first number specified by the second number. For example, 2 ^ 3 returns 8.

          Supported Functions in Expression Sets

          Aggregate
          Function Description Example
          LISTAVG

          Returns the average of numeric (Number, Currency, Percent) values in a list variable.

          This function is applicable to context definition tags, which are used as list variables in expression set versions.

          LISTAVG(OrderAmount), where OrderAmount is a list variable of Currency data type that contains multiple records of order amount.

          The function returns the average of all the values in the list variable.

          LISTSIZE

          Returns the number of items in a list.

          This function is applicable to context definition tags, which are used as list variables in expression set versions.

          LISTSIZE(ProductName), where ProductName is a list variable of Text data type that contains multiple product names.

          The function returns the total number of items or records in the ProductName variable.

          LISTSUM

          Returns the sum of numeric (Number, Currency, Percent) values in a list variable.

          This function is applicable to context definition tags, which are used as list variables in expression set versions.

          LISTSUM(OrderAmount), where OrderAmount is a list variable of Currency data type that contains multiple records of order amount.

          The function returns the sum of all the values in the list variable.

          Date and Time
          Function Description Example
          ADDDAY Adds the specified number of days to the specified date and returns the resulting date.

          ADDDAY(MyDate, 100), where MyDate is a variable of the data type Date with the assigned value of 1999-01-01.

          The function returns 1999-04-11 00:00:00.

          ADDMONTH Adds the specified number of months to the specified date and returns the resulting date.

          ADDMONTH(MyDate, 100), where MyDate is a variable of the data type Date with the assigned value of 1999-01-01.

          The function returns 2007-05-01 00:00:00.

          ADDYEAR Adds the specified number of years to the specified date and returns the resulting date.

          ADDYEAR(MyDate, 100), where MyDate is a variable of the data type Date with the assigned value of 1999-01-01.

          The function returns 2099-01-01 00:00:00.

          AGE Returns the age for the specified birthdate.

          AGE(Birthdate), where Birthdate is a variable of the data type Date.

          The function returns the age on the present date for the value assigned to the Birthdate variable.

          AGEON For a given birth date, returns the age on a specified date.

          AGEON(Birthdate, MyDate), where Birthdate and MyDate are variables of the data type Date with the assigned values of 1999-01-01 and 2001-01-01 respectively.

          The function returns 2.

          DATEDIFF Returns the number of days between two specified dates. If the first date is greater than the second date, the value is returned as a negative number.

          DATEDIFF(StartDate,EndDate), where StartDate and EndDate are variables of the data type Date with the assigned values of 1900-01-1 and 2000-01-01 respectively.

          The function returns 36524.

          DATEVALUE Returns the date value of a Date & Time resource based on the timezone settings in your Salesforce org.

          DATEVALUE(BirthDate), where BirthDate is a resource of Date & Time data type with the assigned value of 2003-05-31T12:15:20.123Z.

          The function returns May 31, 2003.

          EOM

          For a specified date, returns the date of the last day of the month.

          EOM(MyDate), where MyDate is a variable of the data type Date, with the assigned value of 1999-01-11.

          The function returns 1999-01-31.

          MONTH For a specified date, returns the month as an integer (1-12).

          MONTH(MyDate), where MyDate is a variable of the data type Date, with the assigned value of 1999-01-11.

          The function returns 1.

          TODAY Returns today's date. TODAY() returns today’s date.
          YEAR Returns the year of the specified date as an integer.

          YEAR(MyDate), where MyDate is a variable of the data type Date, with the assigned value of 1999-01-11.

          The function returns 1999.

          NOW Returns a date/time representing the current moment. NOW() returns the current date and time.
          Logical and Comparison
          Function Description Example
          ISNULL True if the value of a resource is null.

          ISNULL(Example), where Example is a variable without an assigned value.

          The function returns True.

          ISNOTNULL True if the value of a resource isn’t null.

          ISNOTNULL(City), where City is a variable with an assigned value of Mumbai.

          The function returns True.

          LIKE True if the second parameter contains the first parameter. LIKE(’A’, ‘ABC’) returns true.
          NOTLIKE True if the second parameter doesn't contain the first parameter. NOTLIKE(’A’, ‘ABC’) returns false.
          BEGINS Determines if text begins with specific characters and returns TRUE if it does. Returns FALSE if it doesn't. BEGINS(MyString,CompareText), where MyString, and CompareText are variables of the data type Text . BEGINS(““Expression Set”,“Express”)returns TRUE.
          ISNUMBER Returns TRUE if the string is a number. Returns FALSE if a string isn’t a number. ISNUMBER(MyString), where MyString is a variable of the data type Text . ISNUMBER(“10”)returns TRUE. ISNUMBER(“tty”)returns FALSE.
          Mathematical
          Function Description Example
          ABS Returns the absolute value of a number. The absolute value of a number is the number without its positive or negative sign.

          ABS(MyNumber), where MyNumber is a variable of the data type Number with the assigned value of -25.

          The function returns 25.

          AVG Returns the average of two values. AVG(3,5) returns 4.
          EXP Returns a value for e raised to the power of a number you specify.

          EXP(Number), where Number is a variable of the data type Number, with the assigned value of 5.

          The function returns 148.

          LOG Returns the base 10 logarithm or the power that the number 10 must be raised to for returning the number specified.

          LOG(MyNumber), where MyNumber is a variable of the data type Number with the assigned value of 100.

          The function returns 2. This means that 10 must be raised to the power of 2 to get 100.

          LN Returns the natural logarithm or the power that the constant e (2.718281828) must be raised to for returning the specified number.

          LN(MyNumber), where MyNumber is a variable of the data type Number with the assigned value of 25.

          The function returns 3.22. This means that e, which has the constant value of 2.718281828, raised to the power of 3.22 returns 25.

          MAX Returns the maximum value out of two values. MAX(2,10) returns 10.
          MIN Returns the minimum value out of two values. MIN(2,10) returns 2.
          POWER Returns the result of the first number raised to the power of the second number. POWER(2, 3) returns 8 (2 x 2 x 2).
          SQRT Calculates the square root of a value. SQRT(12 * 3) returns 6.
          SUM Returns the sum of two values. SUM(1,2) returns 3.
          MOD Returns a remainder after a number is divided by a specified divisor. MOD(4, 3) returns 1
          ROUND Rounds the specified number or expression.

          ROUND(3.1415, 2) returns 3.14

          ROUND(3.1415 * 3, 0) returns 9.

          UP(Use with ROUND) Use with ROUND to specify that the rounding result is rounded up (away from zero). ROUND(2.572, 2, UP) returns 2.58.
          DOWN(Use with ROUND) Use with ROUND to specify that the rounding result is rounded down (towards zero). ROUND(2.572, 2, DOWN) returns 2.57.
          HALF_UP(Use with ROUND) Use with ROUND to specify that therounding result is rounded towards the nearest neighbor (up or down) unless the neighbors are equidistant, in which case it rounds up. ROUND(2.575, 2, HALF_UP) returns 2.58.
          HALF_DOWN(Use with ROUND)

          Use with ROUND to specify that the rounding result is rounded rounded towards the nearest neighbor (up or down) unless the neighbors are equidistant, in which case it rounds down.

          ROUND(2.575, 2, HALF_DOWN) returns 2.57.
          HALF_EVEN(Use with ROUND)

          Use with ROUND to specify that the rounding result is rounded rounded towards the nearest neighbor (up or down) unless the neighbors are equidistant, in which case it rounds to the nearest even neighbor.

          Behaves as for ROUND HALF_UP if the digit to the left of the discarded fraction is odd; behaves as for ROUND HALF_DOWN if it is even.

          ROUND(2.57, 1, HALF_EVEN) returns 2.6, which is rounded up to the nearest even one-decimal place.
          String
          Function Description Example
          CONTAIN

          True if the list of strings in the first parameter contains the string in the second parameter.

          Separate the strings in the list of strings in the first parameter with semicolons (;).

          CONTAIN ("Business;Rules;Set", "Rules") returns true.

          CONTAIN ("Business;Rules;Set", "Rule") returns false.

          REVERSE Returns the characters of the string in reverse order. REVERSE(MyString), where MyString is a variable of the data type Text. REVERSE(“Salesforce”)returns “ecrofselaS”.
          FIND Returns the position of a string in another string FIND(search_text,text), where search_text and text are variables of data type Text. FIND(”@”,“admin@salesforce.com) returns 6.
          LEFT Returns the specified number of characters from the beginning of a text string. LEFT(MyString,MyPos), where MyString is a variable of the data type Text and MyPos is a variable of the data type Number.LEFT("www.salesforce.com",3)returns “www”.
          MID Returns the specified number of characters from the starting position of a text string. MID(MyString,NumOfChar,StartingPos), where MyString is a variable of the data type Text, NumOfChar and StartingPos are variables of the data type Number.MID("www.salesforce.com",10,5)returns “salesforce”.
          RIGHT Returns the specified number of characters from the end of a text string. RIGHT(MyString,MyPos), where MyString is a variable of the data type Text and MyPos is a variable of the data type Number.RIGHT("www.salesforce.com",3)returns “com”.
          LEN Returns number of characters in the string LEN(MyString), where MyString is a variable of the data type Text. LEN("salesforce”)returns 10.
          INITCAP Returns string with initial caps - the first character of each word in upper case and the rest of the string in lowercase. INITCAP(MyString), where MyString is a variable of the data type Text . INITCAP(“expression set”)returns “Expression Set”.
          LOWER Converts all the characters in the string in lowercase. LOWER(MyString), where MyString is a variable of the data type Text . LOWER(“Expression Set”)returns “expression set”.
          UPPER Converts all letters in the specified text string to uppercase. UPPER(MyString), where MyString is a variable of the data type Text . UPPER(“expression set”)returns “EXPRESSION SET”.
          SUBSTITUTE Substitutes old text with new text in a text string. SUBSTITUTE(MyString,OldText,NewText), where MyString, OldText, and NewText are variables of the data type Text . SUBSTITUTE(“xyz@salesforce.com”,“xyz”,“itadmin”)returns “itadmin@salesforce.com”.
          TEXT Converts a percent, number, date, date/time, or currency type field into text anywhere formulas are used. TEXT(MyValue). TEXT(Revenue)where Revenue is $20000 returns “20000”.
          TRIM Removes the spaces and tabs from the beginning and end of a text string. TRIM(MyString), where MyString is a variable of the data type Text . TRIM(“  Expression Set  ”)returns “Expression Set”.
          VALUE Converts a text string to a number. VALUE(MyString), where MyString is a variable of the data type Text . VALUE(“10”)returns the number 10.
          BEGINS Determines if text begins with specific characters and returns TRUE if it does. Returns FALSE if it doesn't. BEGINS(MyString,CompareText), where MyString, and CompareText are variables of the data type Text . BEGINS(““Expression Set”,“Express”)returns TRUE.
          LPAD Inserts characters that you specify to the left-side of a text string. LPAD(MyString,PadLength,PadString), where MyString, and PadString are variables of the data type Text . PadLength is a variable of data type Number. LPAD('my_company.com', 15,'z')returns “zmycompany.com”.
          RPAD Inserts characters that you specify to the right-side of a text string. RPAD(MyString,PadLength,PadString), where MyString, and PadString are variables of the data type Text . PadLength is a variable of data type Number. RPAD('my_company.com',15,'z')returns “mycompany.comz”.
           
          Loading
          Salesforce Help | Article