0% found this document useful (0 votes)
141 views

Decision Rules

The document discusses different types of decision rules in PRPC including decision trees, map value rules, decision tables, and when condition rules. It provides details on when each type should be used and how to implement logic for each rule type. Decision trees are best for complex if/then/else statements while map value rules convert property values into results based on ranges. Decision tables and when condition rules evaluate multiple conditions to return single values.

Uploaded by

Ravi Teja
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
141 views

Decision Rules

The document discusses different types of decision rules in PRPC including decision trees, map value rules, decision tables, and when condition rules. It provides details on when each type should be used and how to implement logic for each rule type. Decision trees are best for complex if/then/else statements while map value rules convert property values into results based on ranges. Decision tables and when condition rules evaluate multiple conditions to return single values.

Uploaded by

Ravi Teja
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Decision Rules

1/28/2010
Cognizant Technology Solutions
Nirmalya Sen Sharma
Decision Rules

 What are Decision Rules and how it is useful?

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.

 Categories of Decision rules

 Decision Tree Rules


 Map Value Rules
 Decision Table Rules
 When Condition Rule

 Which Decision to Use at what point of time?

 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.

 How to implement logic in WHEN rule

There are two ways to implement logic in WHEN rule:

1. Use readily available Standard Conditions in ‘Condition’ tab.

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..

 How to implement logic in Decision Tree

 A completed Decision Tree would be looked like the below one.

 Here each row holds individual condition and together they in if .. elseif .. otherwise
format build up a complex business logic.

 Decision Tree can be used to either

A. As Switch-Case statement, i.e., depending on the value of a particular property


specified in Input tab.

B. As nested If …else if…otherwise statement

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

Rules of four other types can reference decision tree rules:

 In a flow rule, a decision tree rule can be referenced in a decision task, identified by the
Decision shape ( ).

Page 6
Decision Rules

 In an activity, a decision tree can be evaluated using the Property-Map-DecisionTree


method or using @(Pega-RULES:DecisionTree).ObtainValue(tools, myStepPage,
decisiontree, inputproperty) function in a Java Step.
 A Declare Expression rule can call a decision tree rule.

Page 7
Decision Rules

 Decision Table

 Purpose

Decision table is an instance of Rule-Declare-DecisionTable rule type. A decision table can


be used to derive a value that has one of a few possible outcomes, where each outcome
can be detected by a test condition. A decision table rule lists two or more rows, each
containing test conditions, optional actions, and a result.

 How to implement logic in Decision Table

 A completed Decision Table would look like following

Using the following button, the condition matrix can be easily implemented

 Additionally, multiple OR conditions can be grouped within a single condition row

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

Decision table rules may be referenced in three other rule types:

 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.

 How to implement logic in Decision Table

 A Completed Map Value would look like following

One Dimensional Map Value

A Two dimensional Map Value

Page 10
Decision Rules

 In order to implement business logic, at first, Input tab needs to be completed.


Evaluation of a map value rule can be based on the value of properties (specified here
as the Row Property and Column Property), or on the value of parameters specified in a
method. Column property or Parameter is only required when this map value will be
used as a double dimensional map value.

 Now in Matrix tab, following buttons can be used to build up matrix

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.

 To complete a row or column label:

1. Click an unlabeled button.


2. Select a comparison operator: < > =, >=, <= or is missing. (If omitted an operator,
the system assumes =.) Select is missing to detect that a property is not present —
not that it is present but has the null value.
3. Enter an expression as the comparand. For each expression, either a literal value, a
property reference or a more complex expression, including function calls.

 Where referenced

Map value rules may be referenced in four rule types:

 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

You might also like