There are two ways you can define rules—either by using IF/THEN or by using Decision Tables. By using a Decision Table, you can create and use business rules in an easy-to-understand format that provides an alternative to the IF/THEN rule format, and it displays multiple related rules in a single spreadsheet-style view. In Rules Designer, a Decision Table presents a collection of related business rules with condition rows, rules, and actions, presented in a tabular form that is easy to understand.
You will use Decision Table for Check Customer rules and use if-then-else for DiscountCheck rules. For the Check Customer rule, you have following scenario :
Quote.customer type
is New
and Quantity
is in the range of 0
to 10
, then Effective Discount
will have a 10% increment and other values will be set as follows:If Quote.CustomerType == New
and Quote.Quantity
is between 0-10, then
Set ApprovalFlow.CustomerType = True Set ApprovalFlow.newEffectiveDiscount = Quote. EffectiveDiscount+10 Set ApprovalFlow..Number of Level for approval = 0 Set ApprovalFlow.Tier1ApprovalNeeded = False Set ApprovalFlow.Tier2ApprovalNeeded = False
Quote.customer type
is New
and Quote.Quantity
is in the range of 10
to 50
, then Effective Discount
will have a 10% increment and other values will be set as follows:Set ApprovalFlow.CustomerType = True Set ApprovalFlow.newEffectiveDiscount = Quote. EffectiveDiscount+10 Set ApprovalFlow..Number of Level for approval = 1 Set ApprovalFlow.Tier1ApprovalNeeded = False Set ApprovalFlow.Tier2ApprovalNeeded = False
Quote.customer type
is New
and Quantity
is greater than 50, Effective Discount
will have a 15% increment and other values will be set as follows:If Quote.CustomerType == New
and Quote.Quantity
is between > 50, then
Set ApprovalFlow.CustomerType = True Set ApprovalFlow .newEffectiveDiscount = Quote.EffectiveDiscount+15 Set ApprovalFlow..Number of Level for approval = 2 Set ApprovalFlow.Tier1ApprovalNeeded = False Set ApprovalFlow.Tier2ApprovalNeeded = True
In this section, you will define the Decision Table.
CheckCustomer.rules
and select Rulesets | Ruleset1.New
.II. Define Rules
III. Add Actions
At runtime, when facts match the Conditions cells, the Rules Engine prepares to run the actions associated with the rule.
Each condition row has a condition expression, and for each rule, a Condition cell. A condition expression is an expression that you build in Rules designer. The condition expression is often a fact property or a function result, but it can be any expression that has a type that can be associated with a Bucketset. Test expressions are often used. These expressions are associated with the built-in Bucketset.
Actions are associated with rules in a Decision Table. In an action, you can call a function, assert a new fact, retract a fact, or modify a fact. In the Actions area, the cells corresponding to an individual action for a rule are called Action cells. When you add multiple actions, the actions that you add in the Actions area are ordered; actions appearing in the higher rows run before actions in the following rows.
Sometimes there may be conflicts in the rules in the Decision Table. Two rules conflict when they overlap and they have different actions. Two rules overlap when at least one of their condition cells has a bucket in common.
Rules designer finds conflicts and you can see the conflicts in the Conflict Resolution row in the Decision Table, when you click Show Conflicts. You can define conflict policy to handle and even resolve such conflicts.
Conflict resolution is done as follows:
You can find that a couple of conflicts are listed in the Conflict section in the Rule designer.
The Rule designer is created without conflict and with Conditions cell and Actions cell values.
3.137.217.220