Working with Expressions
An expression may contain function calls, literals, parameter references, mathematical operators (+, -, *, /), groups of parentheses, or combinations of all of these. You can assign an expression to a decision table condition, a decision table assignment result, a decision tree condition, a decision tree assignment result, or an event rule assignment result. Any referenced data element in a condition must exist and have a non-null value in order for the condition to be evaluated. To assign the expression, you can use the operators = or != for conditions in decision tables and decision trees and = for assignment results in decision tables, decision trees, and event rules. For expressions returning numeric values, you can also use range operators.
Note: If you use a boolean function in a condition that is not of data type boolean, the return value of the function is not compared to the condition, but it is compared against the value True. You cannot use a boolean function in a result that is not of data type boolean, as the return value of a function that is used in a result must match the data type that was specified for the result.
The most powerful component of expressions are function calls. The Business Rules User Interface in My webMethods provides a set of predefined functions that you can use within expressions to perform simple or even complex functionality with a minimal amount of effort. A function call can require arguments. These arguments can be manually entered literal values, they can be mapped to existing parameter elements, they can be the return values of other function calls, or they can be mathematical expressions involving parameter references and/or other function calls.
Five categories of functions exist:
Date Functions.
Conversion Functions.
List and Range Functions.
Math Functions.
String Functions.
For more information about the individual functions, see webMethods Business Rules Reference.
For detailed information about how to add expressions and specify their components, see
Adding an Expression.
Example of a Simple Function
As an example of a simple function, you can check if the input values for a Customer.city parameter start with the string New.
startsWith("New")
Example of a Chained Function
You can call multiple functions by chaining them. As an example of a chained function, you can check if the trimmed input values for a Customer.city parameter end with the string York.
trim().endsWith("York")
Example of a Nested Function
You can nest functions. In this case, the return value of the inner function serves as input parameter for the outer function. As an example of a nested function, you can check if the input values for a Customer.city parameter contains the upper case value of an Order.city parameter.
Contains(%”Order,city”%.toUpper())
Example of a Mathematical Operation
You can perform mathematical operations on the return value of functions or parameter references. As an example of a mathematical operation, you can compute the area of a rectangle:
%"Shapes_1.Rect_Height"% * %"Shapes_1.Rect_Width"%
Example of Parentheses Groups
You can nest sub-expressions in parentheses. As an example of an expression using parentheses, you can compute the perimeter of a rectangle:
(2* %"Shapes_1.Rect_Height"%) + (2 * %"Shapes_1.Rect_Width"%)
Example of an Expression Using a Combination of Components
You can combine the different components of expressions. As an example of an expression using combined components, you can compute the area of a circle rounded and turn the result into a string:
round(pi() * pow((%"Shapes_1.Circle_Diameter"% / 2),2.0)).toString()
Syntax Overview
To make a reference to a parameter element, use %”fullyqualifiedparametername”%, for example startsWith(%”customer.name”%).
To specify a date, use single quotes '2015/02/12 12:00 AM', for example diffInDays('2015/02/12 12:00 AM').
To specify a string array, use single curly braces {}, for example inList({"gold","silver"}).
To specify a string table, use double curly braces {{}}, for example inRange({{"a","c"},{"f","h"}},null).
To specify a date array, use single curly braces {} and a single quote, for example inRange('2015/02/02 12:00 AM','2015/02/12 12:00 AM',{'2015/02/04 12:00 AM','2015/02/05 12:00 AM'}).
To specify a date table, use double curly braces {{}}, and use single quotes for values, for example inRange({{'2015/02/03 12:00 AM','2015/02/06 12:00 AM'},{'2015/02/16 12:00 AM','2015/02/20 12:00 AM'}},null).
To specify a double table and double array, use single curly braces {} and double curly braces {{}}, for example inRange({{10.0,40.0},{50.0,70.0}},{60.0,65.0}).
Example of specifying parameter references inside an array and table: inRange({{10,%"datatypeTest_1.eInteger"%},{30,40}},{35,%"datatypeTest_1.eLong"%}).