Decision Rules
Decision Rules
1/28/2010
Cognizant Technology Solutions
Nirmalya Sen Sharma
Decision Rules
Like conventional programming languages, Decision rule is way in PRPC to logically compare
or compute values.
In PRPC, Decision rule provides the way to logically choose a path over another during
processing; especially when processing has reached a point, where from it can continue with
one of multiple paths.
Decision Tree
• Accepts one input property value, but can evaluate numerous properties
• For business logic currently stored in written documents
• Best used for complex if/then/else statements
Map Value
• Can convert one or two property values into a single result
• For computations based on ranges
• Also for substitution of values
Decision Table
• Can convert multiple property values into a range of return values
• Based on same property inputs with varying values
When
• Evaluates relationship among one or more property values and returns true or false
• Based on simple if/then/else constructs
Page 2
Decision Rules
WHEN rule
Purpose
A when condition rule is an instance of the Rule-Obj-When rule type. It evaluates a Boolean
logical statement involving comparisons among values of properties, to return true or false.
For example, a when condition rule can test whether an amount is greater than zero or a
date is in the future.
2. Alternatively, the expression builder available in ‘Advanced’ tab can be used to create
expression that is more complex.
Page 3
Decision Rules
Where referenced
Rules of many other rule types like in activity rules, flow rules, and through the pega:when
JSP tag in HTML rules can reference when condition rules. For example, a when condition
rules can be referenced in flow rules through ‘Fork’ shape.
Also in Activity, each activity step may reference none or several when condition rules, as
preconditions for a method, or transitions between the just-completed method and the next
step.
As a precondition, a condition rule determines whether the method in the activity step is
executed or skipped. Referenced in a transition, a condition determines what activity
processing flows after completion of the current activity step.
Page 4
Decision Rules
Decision Tree
Purpose
Decision trees are instances of the Rule-Declare-DecisionTree rule type. A decision tree
rule can be to record if .. elseif..otherwise logic that calculates a value in a simple-to-
understand format based on rows of property values, computations, and comparisons..
Here each row holds individual condition and together they in if .. elseif .. otherwise
format build up a complex business logic.
Page 5
Decision Rules
Note: Decision Tree can be used to prepare more complex logic by combining both
above mentioned scenario.
At runtime, the system evaluates the if portion of the array, starting at the top row,
and continues as described here until it reaches a Return statement.
If the system processes the entire tree but does not reach a Return statement, it
returns the Otherwise value.
Where referenced
In a flow rule, a decision tree rule can be referenced in a decision task, identified by the
Decision shape ( ).
Page 6
Decision Rules
Page 7
Decision Rules
Decision Table
Purpose
Using the following button, the condition matrix can be easily implemented
Page 8
Decision Rules
At runtime, the system evaluates the rows starting at the topmost row.
If all the conditions in a row evaluate to true, the processing rule completes and the
value associated with that row is returned to the application.
If no rows in the table evaluate to true, the system returns a default result.
Where referenced
In a flow rule, you can reference a decision table rule in a decision task, identified by the
Decision shape ( ) (Similar to Decision Tree).
In an activity, a decision tree can be evaluated by using the Property-Map-
DecisionTable method or using DecisionTable.ObtainValue() function in a Java Step.
A Declare Expression rule can call a decision table rule.
Page 9
Decision Rules
Map Value
Purpose
Map Value is an instance of Rule-Obj-MapValue rule type. A Map value rule can be used to
create a table of number, text, or date ranges that converts one or two input values, such as
latitude and longitude numbers, into a calculated result value, such as a city name.
Map value rules greatly simplify decisions based on ranges of one or two inputs. Use a map
value rule to record decisions based on one or two ranges of an input value. A map value rule
uses a one- or two-dimensional table to derive a result.
Page 10
Decision Rules
Delete the selected column. Focus moves to the column at its left.
Delete the selected row. Focus moves to the row above.
Insert a new column before (to the left of) the selected column.
Insert a new column after (to the right of) the selected column.
Insert a new row before (above) the selected row.
Insert a new row after (below) the selected row.
Where referenced
In a flow rule, you can reference a map value rule in a decision task, identified by the
Decision shape ( ) (Same as Decision Tree).
In an activity, you can evaluate a map value rule using the Property-Map-Value method
or Property-Map-ValuePair method.
A Declare Expression rule can call a map value rule.
Map value rules can be referenced in other map value rules.
Page 11