Working with Expressions
An expression may contain function calls, literals, parameter references, the 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 link, 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 condition links in 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. webMethods Rules Development provides a set of predefined functions that you can use within expressions to perform simple or even complex functionality for a decision table condition, a decision table assignment result, a decision tree condition, a decision tree assignment result or an event rule assignment result 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.
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.
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.
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()