Rule Types
Business rules are used to enforce more complex requirements that a product and its attributes must meet.
We currently support the following types of business rules:
| Type | Description |
|---|---|
| Groovy rule | Runs a snippet of groovy code. This is the most flexible type of rule |
| Conditionally required rule | If an expression referencing a set of attributes is true, then attribute X is required |
| Dependent attribute rule | If attribute A meets condition, then attribute B is required |
| Uniqueness validation rule | Checks if all products across a channel have unique combination of values on a specified subset of its attributes |
Builders for all types, except uniqueness validation, allow us to control:
| Attribute type id | Type specific parameters |
|---|---|
| id | Rule ID that will show up in the error popup in PDX UI |
| categories | A list of categories that the rule applies to. If this list is empty, the rule will be applied globally for all categories. |
| execution | Determines how the rule is executed. The list of values is found in BusinessRule.ExecutionEnum and are: CONTINUOUS (default), SUBMISSION, AUTOSUBMIT, and ALL |
Code Example:
BusinessRule rule = BusinessRuleBuilder.groovyRule("ID")
.withCategories("categoryA", "categoryB")
.withExecution(BusinessRule.ExecutionEnum.SUBMISSION)
... // add rule specific options here
.build();Updated 6 months ago
