Conditionally required rule
The conditionally required rule builder has the following additional properties:
Property  | Description  | 
|---|---|
expression  | An expression using the attribute aliases. If then the following kind of expressions are possible: Supported operators are  
  | 
aliases  | A list of variable names that are used in expressions in place of attribute IDs. Aliases must be valid groovy variable names  | 
conditional attribute  | The attribute that is required to be non-empty when expression evaluates to true  | 
error message  | The error message that will show up in PDX UI if condition is true, but conditional attribute was not set to a value  | 
Code Example:
BusinessRule rule = BusinessRuleBuilder.conditionallyRequiredRule("RULE_ID")
    .withAlias("x", "NUMBER_ATTRIBUTE_ID")
    .withAlias("y", "UNIT_ATTRIBUTE_ID")
    .withExpression("x == \"100\" and y == \"units\"")
    .withConditionallyRequiredAttribute("PER_HUNDRED_INFO_ID")
    .withErrorMessage("When quantity is set to 100 units, then 'Info per 100' is required")
    .build();This produces the following JSON output when rule is serialized:
{
  "id": "RULE_ID",
  "templateId": "conditionallyRequired",
  "errorMessage": "When quantity is set to 100 units, then 'Info per 100' is required",
  "namedAttributes": {
    "x": "NUMBER_ATTRIBUTE_ID",
    "y": "UNIT_ATTRIBUTE_ID"
  },
  "parameters": {
    "expression": "x == \"100\" and y == \"units\"",
    "conditionalAttribute": "PER_HUNDRED_INFO_ID"
  },
  "requiredContexts": [],
  "execution": "CONTINUOUS",
  "businessRuleScopes": [],
  "staticProperties": {}
}Updated 6 months ago
