Example of Creating an Item Rule Set and Rules

In this example, you create rule sets and rules to implement integrity constraints for a computer motherboard.

The following table summarizes the attribute value assignments required for this scenario.

Attribute

Constraint

Lead Percent

Is Total Lead Mass divided by Unit Weight

Sellable Date (date when item can be sold)

Is 10 days after the Availability Date

The following table summarizes the attribute value validations required for this scenario.

Attribute

Constraint

Minimum CPU Speed (in MHz)

Must be less than Maximum CPU Speed

Purchasable

If set to Yes, then a value for List Price must be set

Unit Height

Can't change by more than 3% without requiring approval

Task Summary

To implement the above constraints, complete the following tasks:

  1. Create an assignment rule set.

  2. Create assignment rules.

  3. Create a validation rule set.

  4. Create validation rules.

  5. Create a composite rule set.

  6. Add the composite rule set to the master rule set.

Create an Assignment Rule Set

In general, rule sets that perform assignments should be executed before validations, so that validation rules can ensure that the results of the assignments are valid.
  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.

    The internal name won't be changeable after the rule set is created.
  4. For Composite, select No.

  5. For Type, select Assignments.

  6. For Association Type, select Item Class.

  7. For Association Name, select Chemicals.

  8. Click Save and Continue.

    The Edit Rule Set page shows a rule set with the specified attribute context, but no rules yet. All the attribute groups in the selected item class are available for us in item rules.

Create Assignment Rules

The assignment to be made by the first rule is:

  • Lead Percent is Total Lead Mass divided by Unit Weight

  1. In the Rules tab of the Edit Rule Set page, select Create from the Actions menu.

  2. In the Create Rule dialog box, enter or select the values shown in the following table.

    Field

    Value

    Sequence

    10

    Name

    Lead Percent

    Description

    Lead Percent is Total Lead Mass divided by Unit Weight

    Return Type

    Generic

    Target Business Entity

    Item

    Target Attribute Group

    Hazard (for an example user-defined attribute group (EFF))

    Target Attribute

    Lead Percent (for an example user-defined attribute group (EFF))

  3. Click OK to accept the header fields.

  4. 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.

    Field

    Value

    Primary If Expression

    (You can leave this field empty. The value true is inserted when this field is null.)

    THEN Expression

    (Consists of the Secondary If Expression and Return Value shown in the following rows)

    Secondary If Expression

    (You can leave this field empty. The value true is inserted when this field is null.)

    Return Value

    round(([Item].[Hazard].[Lead Mass] /  [Item].[Physical Attributes].[Unit Weight]) * 100, 2)

    User Message

    Percent is Mass ($[Item].[Hazard].[Lead Mass]$) divided by Weight ($[Item].[Physical Attributes].[Unit Weight]$).

    Enclosing an attribute expression with dollar sign symbols ( $ ) renders the current value of the attribute in the displayed user message. For the example shown here, the message is:

    Percent is Mass (100) divided by Weight (gms).
  5. Click Validate to validate the expressions in the rule.

  6. Click Save to save the rule set.

    Saving the rule set enters the first assignment rule into set. Since rules are executed in the sequence you specify, you can ensure that values needed by attributes in later expressions are calculated in earlier expressions.

    The assignment to be made by the second rule is:

    • Sellable Date Is 10 days after the Availability Date

    This assignment is equivalent to the code in the following example, which shows how you can use conditional processing in an item rule:

    if ([Item].[Main].[Sellable Flag] == "Yes")
        if ([Item].[Item basic].[Item Class] == "Perishables")
        then [Item].[Marketing].[Sellable Date] = [Item].[Planning].[Availability Date] + 3
     else if ([Item].[Item basic].[Item Class]== "Consumables") 
        then [Item].[Marketing].[Sellable Date] = [Item].[Planning].[Availability Date] + 6
     else [Item].[Marketing].[Sellable Date] = [Item].[Planning].[Availability Date] + 10
    The following steps show how to express that code block in an item rule definition.
  7. In the Rules tab of the Edit Rule Set page, select Create from the Actions menu.

  8. In the Create Rule dialog box, enter or select the values shown in the following table.

    Field

    Value

    Sequence

    20

    Name

    Sellable Date Calculation

    Description

    Calculate Sellable date based on the Availability Date.

    Return Type

    Generic

    Target Business Entity

    Item

    Target Attribute Group

    Marketing

    Target Attribute

    Sellable Date

  9. Click OK to accept the header fields.

  10. In the Details section, enter rule expressions in the expression fields described in the following table. You will have to add an additional two rows of Then Expression by selecting the last row in the table and clicking Add Row.

    Field

    Value

    Primary If Expression

    [Item].[Main].[Sellable Flag] == "Yes"

    (first) THEN Expression

    (Consists of the Secondary If Expression and Return Value shown in the following rows)

    Secondary If Expression

    [Item].[Item basic].[Item Class] == "Perishables")

    Return Value

    [Item].[Planning].[Availability Date] + 3

    (second) THEN Expression

    Secondary If Expression

    [Item].[Item basic].[Item Class]== "Consumables"

    Return Value

    [Item].[Planning].[Availability Date] + 6

    (third) THEN Expression

    Secondary If Expression

    (This field remains empty.)

    Return Value

    [Item].[Planning].[Availability Date] + 10

    User Message

    (This field remains empty.)

    Leaving the last Secondary If Expression blank means it defaults to true and is always selected. No User Message was entered, so nothing is shown to the user.

  11. Click Validate to validate the expressions in the rule. Click Save to save the rule set.

    The assignment rule set is now complete.

Create a Validation Rule Set

Validation rule sets are created in much the same way as assignment rule sets, except that the Type is set to Validation.

  1. On the Manage Rule Sets task page, select Create from the task bar.

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

  3. For Composite, select No.

  4. For Type, select Validations.

  5. For Association Type, select Item Class.

  6. For Association Name, select Computers or Laptops.

  7. Click Save and Continue.

Create Validation Rules

The validation to be made by the first rule is:

  • Minimum CPU Speed (in MHz) Must be less than Maximum CPU Speed

  1. In the Rules tab of the Edit Rule Set page, select Create from the Actions menu.

  2. In the Create Rule dialog box, enter or select the values shown in the following table.

    Field

    Value

    Sequence

    10

    Name

    Maximum Minimum CPU Check

    Description

    Check that Minimum CPU Clock Speed is less than Maximum CPU Clock Speed.

    Severity

    Reject

  3. Click OK to accept the header fields.

  4. In the Details section, enter rule expressions in the expression fields described in the following table.

    Field

    Value

    IF Expression

    (This field remains empty.)

    Validation Condition

    [Item].[Motherboard Spec].[Min CPU Speed] <= [Item].[Motherboard Spec].[Max CPU Speed]

    User Message

    Minimum CPU Speed has to be less than or equal to Maximum CPU Speed.

  5. Click Validate to validate the expressions in the rule. Click Save to save the rule set.

    The validation to be made by the second rule is:

    • If Purchasable is set to Yes, then a value for List Price must be set

    This validation demonstrates how the value of one field must be value based on the value of another field.

  6. In the Rules tab of the Edit Rule Set page, select Create from the Actions menu. In the Create Rule dialog box, enter or select the values shown in the following table.

    Field

    Value

    Sequence

    20

    Name

    Require List Price

    Description

    List Price must be set if Purchasable is set to Yes

    Severity

    Reject

  7. Click OK to accept the header fields. In the Details section, enter rule expressions in the expression fields described in the following table. The ! in the function expression !isnull() negates the logical result of the expression.

    Field

    Value

    IF Expression

    [Item].[Purchasing].[Purchasable] == "Yes"

    Validation Condition

    (!isnull([Item].[Purchasing].[List Price]))

    User Message

    If Purchasable is set to Yes then List Price can't be null.

  8. Click Validate to validate the expressions in the rule. Click Save to save the rule set.

    The validation to be made by the third rule is:

    • Unit Height can't change by more than 3% without requiring approval.

    This validation demonstrates how to check the new attribute value against the value that's currently in production. If this validation fails, then the user will be required to create a change order for this change.

  9. In the Rules tab of the Edit Rule Set page, select Create from the Actions menu. In the Create Rule dialog box, enter or select the values shown in the following table.

    Field

    Value

    Sequence

    30

    Name

    Height Change

    Description

    Unit Height can't change by more than 3%.

    Severity

    Needs Approval

  10. Click OK to accept the header fields. In the Details section, enter rule expressions in the expression fields described in the following table.

    Field

    Value

    IF Expression

    (This field remains empty.)

    Validation Condition

    abs(percent([Item].[Physical Attributes].[Height])) > 3.0

    User Message

    A unit height change of 3% requires a change order.

    The percent() function returns the percentage change of the new value to the value in production. This change can be positive or negative, hence the abs() function converts it to an absolute change.

  11. Click Validate to validate the expressions in the rule. Click Save to save the rule set.

    The validation rule set is now complete. Click on the Usage tab to review all the attributes used in this rule set. Click Save and Close to return to the Manage Rule Sets page.

Create a Composite Rule Set

Now create a composite rule set that includes both of the rule sets that you just created. This is the rule set that you will assign to the Item entity in the final step to activate the rules we have created.
  1. On the Manage Rule Sets task page, select Create from the task bar.

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

  3. For Composite, select Yes.

  4. For Type, select Mixed.

    In more complex scenarios, you might have multiple layers of composite rule sets, some of which you only want to contain validations or assignments rules. But eventually you will want to include both kinds of rules.

  5. Click Save and Continue.

  6. On the Included Rule Sets tab of the Edit Rule Set page for the new composite rule set, select Add from the Actions menu.

  7. In the Select and Add: Rule Sets dialog box, search for and select the assignment rule set that you created, then click the Apply button.

  8. Repeat the search and selection step to add the new validation rule set to the composite rule set.

  9. The rule sets will be executed in the order that they're listed in the Included Rule Sets list, so it's important to put validations after assignments if you want to validate some of the assignment results that you calculated.

  10. Click Save and Close.

Add the Composite Rule Set To the Master Rule Set

The rules you created aren't active until you add them to the Master Rule Set, as described in the following steps. Also, note that the Draft check box should be deselected for a rule set to be executed at runtime. Draft rule sets aren't run during regular transactions.

  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 composite 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.

    You are now ready to test the validations. When you make the relevant item updates, the updated values should be validated by the rules that are triggered, and the error messages should appear.

    You can also examine some of the other tabs on the Edit Rule Set page. In the validation and assignment rule sets the Rule Sets Where Included tab should now show the composite rule set that you added them to. In the composite rule set, the Attributes section on the Usages tab should show the item assignments for the rule sets.

Completeness Score

The Completeness Score indicates the percentage of completeness for an item and it’s based on the values that are returned for specific attributes.

You can create a product rule to set the completeness score on an item in the Product Information Management work area. This works well when you’re enriching the item information based on different statuses or lifecycle phases.

For example: You can set a rule that specific attributes of the item must meet certain set criteria prior to moving to the Production status. The user can’t manually enter this attribute. The value of this attribute is derived from an Assignment Rule. This rule may be written based on the values provided across attributes spread across different attribute groups.

For example: You can change the item status to active if the completeness score is more than 80%. This ensures that the item has the necessary information that downstream products can use.