How to evaluate a decision tree rule and handle errors
Your application can call a decision tree rule from an activity, or in an expression.
From an activity
Use the Property-Map-DecisionTree method. The return value from the decision tree is stored into the property (or parameter or local variable) specified in the 'PropertyName' field, much as in the left-hand side of a Property-Set.
Forthe DecisionTreeName parameter, enter the second key part of Rule-Declare-DecisionTree rule.
The Input parameter is optional and, if not blank, overrides the default input (if one is specified) in the decision tree rule.
Check AllowMissingProperties to cause processing to continue normally even when if a referenced property is not present (has no value). For scalar property, a property is missing if it has a value of ""./.
If you do not check the AllowMissingProperties parameter, then your application must handle the case of a missing property. This functionality is useful. For example, assume you have a decision tree that calculates the value of a used vehicle. When given input of "motorcycle", it needs a value for the mileage. If the property mileage is not present or has a null value, the user can then be prompted for the mileage.
To check for this occurrence, include the following test in the step's transition (or the next step's precondition). Execution of a decisiont ree rule returns an output parameter.
Param.DecisionTreeStatus == "NotFound"
If true, the missing property information is stored in:
-- in the syntax [class].[property name].
Also, when the ParamDecisionTreeStatus is "NotFound", the return value is always "".
From an expression
In an expression, call the ObtainValue() standard function to access the value of a decision tree. The first format always has parameter bAllowMissingProperties set to false.
@(Pega-RULES:DecisionTree).ObtainValue(tools, myStepPage, [decision tree name], [input])
@(Pega-RULES:DecisionTree).ObtainValue(tools, myStepPage, [decision tree name], [input], [bAllowMissingProperties])
In a flow, you can use the Decision shape to call a decision tree rule. Missing properties are always allowed.
In Declare Expression rules, you can set a property to the outcome of a decision tree. Missing properties are handled by the Expressions facility.