Creating a business rule
About this task
Each rule exists in the context of a specific decision and this decision might require more than one rule to detail its decision logic. A rule uses the vocabulary of the input data that the decision is based on, and selects a value for the decision output.
Procedure
Results
You can now use the rule editor to complete the different parts of your rule.
For more information about how to build rules, see Working with business rules. The rule language reference manual is available in the Rule language section.
Example
For example, consider a decision that gives a discount that depends on the category of a customer and how much he spent.
When you create a rule, the rule template in the preview only contains the action that sets the
decision, with the construct set decision to. You can
generate a rule that is closer to the decision logic that you want to express by selecting the input
data that the rule needs to make the decision. Here the input data is the customer category and the
value of the shopping cart of the customer. When they are selected in the list of criteria, an
if part with conditions that use these inputs is added
to the rule template.
The conditions contain placeholders where you will indicate actual values. The types of these values and the default constructs depend on the type of data that you defined in your data model and on the node types in the diagram.
Similarly, the output of the decision is the amount of the discount. Therefore, the placeholder for the value of the decision indicates that is a number, based on the output type of the decision.
Now, let's say that the actual decision logic consists in giving a discount of 10 to Gold customer whose cart value is over 100. In the rule editor, the rule template can be modified to represent this decision logic. In the following example, the construct to evaluate the shopping cart value has been replaced with one that is more relevant to this case, and the placeholders for the shopping cart, category, and discount values have been filled with specific values.
if 'shopping cart value' is more than 100 and 'customer category' is "Gold" then set decision to 10;