Apply Logic in Business Rules

Use guidelines to help you create a business rule.

Create Rules That Don't Conflict

  • Make sure your rules won't cause a conflict at run time.

    For example, assume you write rule x that assigns a fulfillment line with item type of server to one process, and you write rule y that assigns server item ABC to another process. A conflict might happen. You must revise rule x so it doesn't specify server item ABC. Oracle Business Rules provide details about potential conflicts after you save the rule.

  • If your rule compares one data object to another data object of the same type, then use advanced mode and create two variables, one variable to represent each data object.

    You must specify that variable one is not the same as variable two. Set up this test.

    variable1 is not variable2

    If you don't set up this test, then Oracle Business Rules will use variable1 and variable 2 to represent the same object instance when it determines the rule to apply.

  • Make sure each rule evaluates to a single result. For example, if you write two rules for a fulfillment task, then make sure only one rule evaluates to true. Assume you write two rules.

    If Task Type = Shipment return Shipment 
    If Task Type = Shipment and Customer = GOLD return Third Party Shipment
    

    These rules look different but they each evaluate to true when Task Type equals Shipment and Customer equals GOLD. To avoid this problem, write If, Then, Else rules in Visual Information Builder to make sure your rules are mutually exclusive.

Use Rule Logic in Visual Information Builder

Defining Rule Logic When You Use Visual Information Builder

Note

  1. Notice the entity. You enter the attribute, such as Order Type, and then the entity that contains the attribute, such as Order Header, displays immediately under the attribute.

    Most attributes on the order header are different from attributes on the order line. For example, the order header includes the Order Type attribute but the order line doesn't. However, the order header and the order line contain similar or identical attributes. For example, the order header and the order line each include attribute Shipping Instruction. If your rule must reference Shipping Instruction on the order header, then make sure you use the order header entity.

  2. Is in the List. Use Is in the List to examine the list of values that the attribute references instead of writing an OR condition. For example, the list of values for Order Type includes Mixed Orders and Standard Orders. If you don't use Is in the List, then it might be necessary to write a series of OR conditions. For example:

    If Order Type equals Mixed Orders, or If Order Type equals Standard Orders
  3. Add the description. Description for the IF statement is optional. However, you can use it to quickly scan your rule logic without having to drill down into the rule to determine the purpose of the statement. You can also add a description for the Then clause.

  4. Make sure the object isn't empty.

    Note: If your rule depends on a value, and if the rule references an attribute that doesn't contain a value, then it might fail with unpredictable results, such as a error. For example:orAvoid this problem. Make sure the value of any attribute that your rule references isn't empty.

    Here's an example of how to do it in Oracle Business Rules.

    example of how to do it in Oracle Business Rules.

Use rule logic in Visual Information Builder to simplify creating and managing your rule.

Using rule logic in Visual Information Builder to simplify creating and managing your rule

Note

  1. Structure your rule.

    • Put all your logic in one rule instead of spreading it across more than one rule.

    • Write one rule that includes more than one IF_THEN_ELSE statement instead of writing more than one rule.

    • Add an IF THEN ELSE structure.

    • Nest your rules, such as adding another IF after an ELSE.

  2. To look for values that aren't in the list, write a rule that looks for values in the list, then add a False condition. Use False directly in the IF statement to implement a NOT condition rather than adding another rule.

Set the Priority

If you set up more than one rule to meet the same business requirement, then set the priority.

Writing More Than One Rule

The priority determines the sequence that Order Management uses when it applies the rule. Assume you set priority to Medium for rule x and to High for rule y. Assume the conditions in the If statements in rules x and y evaluate to true. Order Management will apply rule y on the orchestration process first, and then will apply rule x.

For details, see Guidelines for Pausing Orchestration Processes.

Make Sure Rules Are Mutually Exclusive

Make sure the rules in a single rule set are mutually exclusive.

Make sure the rules in a single rule set are mutually exclusive.

A rule set is a group of rules that run together to achieve a business objective. For example, assume you create a pause rule and a release rule on a pause task. The pause rule and release rule together constitute one rule set. Oracle Business Rules runs all the rules in a rule set. To avoid logic problems, make sure no two rules can be true at the same time, or false at the same time.

Create If Statements

  • Use an If Then format that uses natural language when you first begin writing your rule. For example:

    If the item type is server, then add extra packing to the shipping instructions.
  • Remove dependencies where the result of one rule changes the If statement of another rule in a way that causes infinite looping.

  • Consider the outcome under a variety of data inputs. The If Then statement is the most common statement. You can also use If Then Else in advanced mode.

  • Add the equivalent of an Else clause so your rule can handle the situation where no condition is met. To avoid an interruption in processing, this is particularly important when your rule assigns an orchestration process or routes processing to a fulfillment task.

  • Use a bucket set to simplify If logic in the decision table. Use parameters on actions to provide different values for the same attribute in each rule.

  • Use a decision table when you require more than one rule that uses the same set of If statements and Then statements.

Create If Statements in Oracle Business Rules

Use different conditions in Oracle Business Rules depending on the update that you're using.

Old Updates

Current Update

Description

For Each Case

Each

Repeat for each of the row that satisfies the conditions of the If statement.

There is a case where

At least one

At least one of the rows satisfies the conditions of the If statement.

There is no case where

None

None of the rows satisfies the conditions of the If statement.

Aggregate

Aggregate

Aggregate fulfillment lines before you send them to your fulfillment system.