Creating a business rule
About this task
A business rule defines the specific actions to take when certain conditions are met. A basic
rule uses an if-then statement to associate a condition (if) with an action
(then).
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 the spent.
When you create a rule, the rule template contains a simple expression, with the construct
if <condition> then <action>. 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 'discount' to 10;