We'll create a more complex decision rule that uses a combination of static cases and dynamic ones through action tables. This rule will accept a product name, and return back it's cost and price.
Enter the specific rule properties as follows. To read about the other properties, review the Rules help:
Property | Value | Description |
---|---|---|
Rule Name | DecisionRule_ActionTable | You can choose any meaningful name you like. |
Rule Usage | Empty | This rule usage provides the necessary input and output parameters necessary for a rule's purpose. Select the Empty Rule Usage for this example. |
Rule Type | Decision | This type of rule is meant will launch a special Decision Builder after you save the rule. |
Click Add and create the following Parameters:
Name | Type | Default | Behavior | Length |
---|---|---|---|---|
ProductName | Text | Input | ||
Cost | Number | Output | ||
Price | Number | Output |
Make sure to keep the Default and Length values empty.
Enter the predicate properties as follows:
Property | Value | Description |
---|---|---|
Expression Type | SQL Non Query | There are three options available, we'll do SQL Non Query for this example and then later discuss the other options. |
SQL Body | BEGIN IF :ProductName = 'Dog' THEN | In this Predicate we check if ProductName is Apples, if it is then we set the system parameter Result to 1 indicating that this is the case we want to evaluate. |
Enter the condition value properties as follows:
Property | Value |
---|---|
Expression Type | Constant |
Value | 100 |
Enter the condition value properties as follows:
Property | Value |
---|---|
Expression Type | Constant |
Value | 100 |
Next we need to create a Business Object that will hold dynamic cases.
Click on the New Business Object button. The New Business Object page appears.
Property | Value | Description |
---|---|---|
Object Name | ProductAction | Use this name for the example. |
Template | System -> Action Table | This template creates the required attributes to work with the Decision Rule. |
Add the following Attributes:
Name | Type |
---|---|
CostBody | TextArea |
CostType | Integer |
PriceBody | TextArea |
Enter the predicate properties as follows:
Property | Value |
---|---|
Expression Type | Reference Table |
Table Name | ProductAction |
Predicate | Condition |
Predicate - Type | Attribute -> ConditionType |
Sort | Id |
Sort - Type | Ascending |
Cost | CostBody |
Cost - Type | Attribute -> CostType |
Price | PriceBody |
Price - Type | Type -> Constant |
Click the Run button on the bottom left. Scroll down to the Rule Result text area and you should see the following result:
{"DATA":{"root_DecisionRule_Products":{"RETVAL":"1","COST":"100","PRICE":"100"}}} |
Enter the Parameter properties as follows:
Parameter | Value |
---|---|
Condition |
|
ConditionType | 3 |
CostBody | 9 |
CostType | 1 |
PriceBody | 11 |
Change the Parameter properties as follows:
Parameter | Value |
---|---|
Condition | BEGIN :Result := 0; IF :ProductName = 'Cat' THEN :Result := 1; END IF; END; |
ConditionType | 3 |
CostBody | BEGIN :Result := 60 * 0.75; END ; |
CostType | 3 |
PriceBody | 60 |
Click the Run button on the bottom left.
Go back to the detail page of the Decision Rule, if you didn't close anything it would be the tab named Rule - DecisionRule_ActionTable on the top of the screen.
Click the Run button on the bottom left. Scroll down to the Rule Result text area and you should see the following result:
{"DATA":{"root_DecisionRule_Products":{"RETVAL":"1","COST":"45","PRICE":"60"}}} |