You are here:
Create and Test a Constraint in Constraint Rules Engine
Create a constraint using the Constraint Builder and test it within the Configurator UI. The example defines constraints for default values based on a selected state and product structure.
| Permission Set Name | Description |
|---|---|
| Product Configuration Constraints Designer | Create and manage constraint types and rules in Configurator with Constraint Rules Engine. |
In this example, you’ll define a constraint that sets default values for vehicle make and model based on the selected state in an auto insurance configuration. The constraint ensures:
- State defaults to CA
- If State is CA, vehicle Make defaults to Lexus and Model to RX350
- From the App Launcher, find and select Constraint Models.
- Click New Constraint Model.
- Enter a name and API name for the constraint model.
- Specify InsuranceContext in Context Definition.
- Save the constraint model.
- On the Details page, select the version name of the constraint model.
- In the Constraint Builder header in the upper left corner, select CML Editor.
-
In the Constraint Builder, copy this constraint into the editor.
type AutoInsurance { string State; relation vehicles : Vehicle; constraint(State=="CA", "State must be CA"); } type Vehicle { string Make; string Model; constraint(Make=="Lexus", "Make must be Lexus"); } type Auto : Vehicle { constraint(Model=="RX350", "Model must be RX350"); }If your Auto Root product doesn’t include a State attribute, remove the State field and the corresponding constraint from the constraint definition.
- Save your changes.
-
Create a Type Association for the AutoInsurance type.
- Click AutoInsurance in the Types section of the builder.
- In the Associations tab, select Type Association.
-
Click Create Association and then select these values in
Association Details.
- Object Category: Product
- Object to Map: Auto Root
- Save your changes.
-
Create a Relationship Association for the AutoInsurance type.
- Click AutoInsurance in the Types section of the builder.
- In the Associations tab, select Relationship Association.
-
Click Create Associations and then select these values.
- Type Relationship: Vehicles
- Bundle: Auto Root
- Product or Product Class: Auto Vehicle Class
- Save your changes.
-
Create a Type Association for the Vehicle type.
- Click Vehicle in the Types section of the builder.
- In the Associations tab, select Type Association.
-
Click Create Association and then select these values.
- Object Entity: Product Classification
- Object to Map: Auto Vehicle Class
- Save your changes.
-
Create a Type Association for the Auto type.
- Click Auto in the Types section of the builder.
- In the Associations tab, select Type Association.
-
Click Create Association and then select these values.
- Object Entity: Product
- Object to Map: Auto Bundle
- Save your changes.
- Save and activate your constraint model.
Test the Constraint in the Configurator
- Create or open a quote and then set or update the Transaction Type to Advanced Configurator (or your custom label for Advanced Configurator).
- Add the Auto Root product to the quote.
- Select the Configure option against the Auto Root quote line item.
- Ensure that the default value of the State attribute ia CA.
- Change the state to NV.
- Click Add Vehicles, then select Auto Bundle.
- Click the configure icon next to Auto Bundle and verify that Make defaults to Lexus and Model defaults to RX350.

