Define Rule Sets and Item Rules

You can define item rules to enforce integrity constraints on the attributes of items and structures.

To define item rules, you must :

  1. Define rule sets to contain the rules.

    Rule sets can be used for assignments, validations, or blending.

  2. Define rules in the rule sets.

    The procedure for defining rules differs among assignment, validation, or blending rule sets.

  3. Enable the rule sets for execution.

The details for these procedures follow.

Define Rule Sets

The table following these steps provides details about the fields for defining rule sets.

  1. In the Product Information Management work area, select the Manage Item Rule Sets task.

  2. Select Create from the Manage Rule Sets task bar.

  3. In the Create Rule Set dialog box, enter a name and optional description.

  4. Select a value for Composite.

  5. Select a value for Type, to determine the type of the rule set.

  6. In the Association Type field, select the type of association to use for determining valid attribute expressions.

  7. In the Association Name field, select a name to qualify the association type.

  8. Select Draft, so that the rule set won't be triggered until you're satisfied with its behavior.

  9. Click Save and Continue.

  10. Create one or more rules within the rule set. Unless you selected Yes for Composite, you can only create rules of the Type that you chose.

    Continue to the procedure for creating assignment or validation rules.

Rule Set Field

Purpose

Display Name

Visible name for the rule set. You can modify this name later.

Internal name

Generated automatically when you leave the Display Name field. May contain only letters, digits, underscores, and periods. Can't be changed after the rule set is created.

Description

Optional description of the rule set.

Composite

Values are Yes or No.

Composite rule sets contain other rule sets, either assignment type, validation type, or both. You can also use composite rule sets to aggregate rule sets that operate on different attribute groups and item classes.

You don't select associations for a composite rule set. The associations belong to the rule sets contained in the composite set.

If you select Yes, then you can select the rule set type as Mixed, so that the composite set can contain a mixture of assignment and validation rule sets.

Blending rule sets can't be composite.

Type

The type of the rule set, which determines the type of rules that can be created in the set. You can't change the type of a rule set after creating it.

The available types are:

  • Assignments

  • Validations

  • Blending

  • Mixed

Association Type

Associates the rule set with a set of attributes. When combined with an association name, the association type determines the set of attributes that are considered valid in the rule expressions that you enter.

The available association types are:

  • Attribute group: Only the attributes in the specified attribute group can be used in expressions in the rule set.

  • Item class: Only the attributes in the attribute groups that are valid for the specified item class can be used in expressions in the rule set.

  • Change order type or New item request: Only the header attributes (including descriptive flexfields) of the change order or new item request can be used.

If Type is Blending, then change order type and new item request aren't available.

Association Name

The name of the specific associated type that's the source of valid attributes for rule expressions. For example, if you selected an association type of Attribute group, then search for and select the name of an attribute group.

Draft

Select to put this rule set into Draft status. Draft status prevents the rule from being triggered during item transactions, and allows rule impact analysis on the rule set.

Note: You can't define a rule independently of a rule set. The rule set provides essential contextual data for the rule.

Define Item Assignment Rules

Define assignment rules to set the values of item attributes based on conditions that you specify.

  1. Create or open a rule set of type Assignments.

  2. In the Rules tab of the Edit Rule Set page for the rule set, select Create from the Actions menu.

  3. In the Create Rule dialog box, enter an integer in the Sequence field.

  4. Provide a name and description for the rule.

  5. Select a Return Type.

  6. If you selected Return Type as Generic, Target Business Entity is enabled and required.

    1. Select a value for Target Business Entity. Target Attribute Group is then enabled and required

    2. Select a value for Target Attribute Group. Target Attribute is then enabled and required.

    3. Specify a value for Target Attribute.

  7. The following table provides details about the fields defining the header level of the rule. You can modify these values after the rule has been created.

    Rule Field

    Purpose

    Sequence

    An integer. This sequence number determines the order in which the rule will be triggered when the rule set is triggered.

    Name

    Name for the rule. You can modify this name later.

    Description

    Optional description of the rule.

    Return Type

    The result of the assignment defined by the rule. The available return types are:

    • Catalog category: Assigns an item to a catalog category.

    • Generic: Assigns a value to an attribute.

    • Item description: Assigns a description to an item.

    • Item number: Assigns an item number to an item.

    • Organization: Assigns an item to an organization.

    Target Business Entity

    If Return Type is Generic, a business entity must be specified, to provide an attribute association for validating expressions. The entities are:

    • Item

    • Revision

    • Supplier

    A rule can assign values to revision attributes or supplier attributes based on conditions on item attributes, but the reverse isn't true. That is, a rule can't include revision attributes or supplier attributes in a condition for a rule whose target attribute is an item attribute.

    Target Attribute Group

    The attribute group for the target business entity. Only enabled if Return Type is Generic.

    Target Attribute

    The attribute for the target attribute group. Only enabled if Return Type is Generic.

  8. Click OK to accept the header fields.

  9. In the Details section, enter rule expressions in the Expression fields described in the following table.

    To ensure that valid attribute group and name expressions are used in rules, you can right-click in one of the expression fields and select Insert Attribute, then use the Insert Attribute dialog to populate attribute expressions into the rule fields.

    Rule Field

    Purpose

    Primary If Expression

    Optional. An attribute expression that must evaluate to true or false, which determines whether the assignment is to be performed. You can enter true or false as a valid expression. This field can be empty if an expression isn't required.

    THEN Expression

    Required. Composed of:

    • Secondary If Expression: A condition that further determines whether the assignment is to be performed. This field can be empty if an expression isn't required.

    • Return Value: The value resulting from the assignment. Agrees with the return type that you specified.

    You can manage additional rows of the THEN Expression with the edit controls on the task bar. The rows are evaluated in the sequence of the expression rows. The execution is halted when the first THEN expression evaluates to True.

    User Message

    Optional. Displayed to the end user when the rule successfully assigns a value to the target attribute. You can select Hide user message to retain the definition of the message while suppressing it from runtime display.

    It's not necessary to check whether attribute values are null (which includes division by zero). Null values normally cause the assignment to be ignored, unless you explicitly want to test for a null value with the isnull() function. This feature facilitates incremental processing of an item, where the item might not be completely filled in until the end of a process.

  10. Click Validate to validate the expressions in the rule. A message informs you whether there is an error, or confirms that the rule definition is valid.

  11. Define more rules in the rule set, as needed. You can modify the execution order of the rules by editing their sequence numbers.

  12. Click Save to save the rule set.

  13. Add the rule set to the master rule set, to enable its operation during item transactions.

Define Item Validation Rules

Define validation rules to validate the values of item attributes based on conditions that you specify.

  1. Create or open a rule set of type Validations.

  2. In the Rules tab of the Edit Rule Set page for the rule set, select Create from the Actions menu.

  3. In the Create Rule dialog box, enter an integer in the Sequence field.

  4. Provide a name and description for the rule.

  5. Select a level of Severity for the action produced by the rule if the validation fails. Severity only applies to validation rules.

    Select Valid Component Rules only if your rule is validating component types, using the component_type() function.

  6. The following table provides details about the fields defining the header level of the rule. You can modify these values after the rule has been created.

    Rule Field

    Purpose

    Sequence

    An integer. This sequence number determines the order in which the rule will be triggered when the rule set is triggered.

    Name

    Name for the rule. You can modify this name later.

    Description

    Optional description of the rule.

    Severity

    The severity of the action that's produced if the validation fails.

    • Warning: The explanation message is displayed to the user, but the business entity can still be saved

    • Needs Approval: The data requires that a change order be created.

    • Reject: The business entity can't be saved until the validation passes. You can increase the severity of this validation result by selecting Stop further processing when rejected.

  7. Click OK to accept the header fields.

  8. In the Details section, enter rule expressions in the Expression fields described in the following table.

    To ensure that valid attribute group and name expressions are used in rules, you can right-click in one of the expression fields and select Insert Attribute, then use the Insert Attribute dialog to populate attribute expressions into the rule fields.

    Rule Field

    Purpose

    If Expression

    Optional. An attribute expression that must evaluate to true or false, which determines whether the validation is to be performed. The expression must evaluate to true for the validation to occur. You can enter true or false as a valid expression. This field can be empty if an expression isn't required.

    Validation Condition

    Required.

    This condition is evaluated when the result of the If Expression is true. When the validation condition evaluates to false, then the validation fails, and the action for the selected severity is executed. The User Message is also displayed, for failures.

    User Message

    Optional. Displayed to the end user only when the Validation Condition evaluates to false.

    It's not necessary to check whether attribute values are null (which includes division by zero). Null values normally cause the validation to be ignored, unless you explicitly want to test for a null value with the isnull() function. This feature facilitates incremental processing of an item, where the item might not be completely filled in until the end of a process.

  9. Click Validate to validate the expressions in the rule. A message informs you whether there is an error, or confirms that the rule definition is valid.

  10. Define more rules in the rule set, as needed. You can modify the execution order of the rules by editing their sequence numbers.

  11. Click Save to save the rule set.

  12. Add the rule set to the master rule set, to enable its operation during item transactions.

Enable Rule Sets and Rules

Before a rule can run, you must enable the rule set that contains it. To enable a rule set, you must assign it to the master rule set, either directly, or by adding it to a rule set that's included in the master rule set.

The master rule set (named MASTER_RULE_SET) is a predefined rule set that contains other rule sets, which can in turn include other rule sets. In each composite rule set, a sequence number controls the order in which its included rule sets are to be executed at runtime.

  1. On the Manage Rule Sets page, search for MASTER_RULE_SET and edit it.

  2. On the Edit Rule Set page for MASTER_RULE_SET, on the Included Rule Sets tab, select Add from the Actions menu.

  3. In the Select and Add: Rule Sets dialog box, search for your rule set by name, or by one of the other fields that define a rule set.

  4. Select your rule set from the search results, and click OK.

  5. Your rule set appears in the list of rule sets included in the master rule set, with the next available sequence number, which determines the order of execution of the included rule set. You can select Edit Sequence from the Actions menu to modify the sequence.

  6. Click Save to save the master rule set.

  7. On the Edit Rule Set page for your own rule set, the Rule Sets Where Included tab shows that your rule set is included in the master rule set.

Optimize Rule Performance

You can optimize the performance of your rules by running a scheduled process.

After you define rules in a rule set, each rule is compiled when it's first triggered at runtime, and its definition is then cached in a database. You can run the scheduled process Optimize Rules to force the compilation and caching of all of the rules in all of your rule sets. The cached rule definitions persist in the database across restarts of the application server.

To run the scheduled process Optimize Rules, you use can either of these methods:

  • While working with rule sets on the Manage Rule Sets page, you can select Optimize Rules from the Actions menu. This action runs the scheduled process. Take note of the process ID, then go to the Scheduled Processes work area to check on the process.

  • In the Scheduled Processes work area, you can directly schedule the Optimize Rules process.

  • This process doesn't have any process parameters.

    The log file for the process contains informational messages about any rules that didn't compile successfully.

You might need to run the Optimize Rules scheduled process again if:

  • You have imported new rules from another installation using the setup data export and import processes in the Setup and Maintenance work area. When you import rules data this way, the rule definitions aren't recompiled. These imported rules will still run successfully on the target installation but they won't be recompiled until the first time they're triggered at runtime after the server has been restarted. You can run the Optimize Rules scheduled process to force the recompilation and caching of all the imported rules.

  • A resolution to a known issue requires rule text to be regenerated. The Optimize Rules scheduled process performs the required regeneration.