How to Add Rules How to Define a Test in a Rule

Working with Rulesets and Rules 4-7 more information on rule validation, see Section 4.4.2, Understanding Rule Validation . As the number of rules in a ruleset increases, you can configure Rules Designer to filter the list of rules to show only rules of interest. For more information, see Section 4.2.3, How to Use a Filter to Display Matching Rules in a Ruleset .

4.3.1 How to Add Rules

To create a rule you first add the rule to a ruleset, and then you insert tests and actions. The actions are associated with pattern matches. At runtime when a test in the IF area of a rule matches, the Rules Engine activates the THEN action and prepares to run the actions associated with the rule. Rules Designer lets you create a rule where by default the rule fires for each matching fact. To enable other options, where the same fact type matches more than once, or never, you select Advanced Mode. For more information on advanced mode and showing advanced settings, see Section 4.5, Using Advanced Settings with Rules and Decision Tables . To add rules in a ruleset: 1. In Rules Designer, select a ruleset from the Rulesets navigation tab. 2. In the View field, select IFTHEN Rules. 3. Click Add to add a rule. For example, click Add to add a rule named Rule_1, as shown in Figure 4–8 . Figure 4–8 Adding a Rule in a Ruleset

4.3.2 How to Define a Test in a Rule

To create a test in a rule you add conditions for facts. For example, with a sample CustomerOrder fact with an annual spending property, you can add a test to 4-8 Oracle Fusion Middleware Users Guide for Oracle Business Rules determine if a customer order is associated with a high value of spending, based on the annual spending for the customer. Note that you can use bucketsets to limit the values for tests and actions in rules. For more information, see Section 4.11, Using Bucketsets as Constraints for Options Values in Rules . Figure 4–9 shows this sample rule. Figure 4–9 Adding a Test to a Rule At runtime, when this rule is processed the Rules Engine checks the facts against rule pattern tests that you define to find matching facts. For this sample rule, Rule_1, when a fact matches the Rules Engine modifies the fact and then modifies the value property to High. To define tests in rules: 1. In Rules Designer, select a ruleset from the Rulesets navigation tab. 2. In the View field, select IFTHEN Rules this is the Rules Designer default. 3. Add or select the rule you want to use, for example, select Rule_1. 4. In Rule_1, in the IF area, select insert test. 5. For a test, the IF area of a rule includes a left-hand-side operand and a right-hand-side operand, as shown in Figure 4–10 . Figure 4–10 Rule Test with Left-hand-side operand and Right-hand-side operand 6. In a test, you replace the left-hand-side operand with a value. To do this, select the left-hand-side operand. This displays a text entry area and a list, as shown in Figure 4–11 : Working with Rulesets and Rules 4-9 Figure 4–11 Configuring the Left-hand-side Operand of a Test in a Rule

a. To enter a value use the list to select an item from the value options.