Constraint Modeling Language

Constraint Modeling Language (CML) is a domain-specific language that defines models for complex systems. For product configuration, constraint models describe real-world entities and their relationships to each other.

Constraint models enforce business logic declaratively, without the need for extensive code in a general-purpose programming language. In Product Configurator, a product designers or admin create a constraint model in CML, then Constraint Rules Engine compiles the CML code. The constraint model enforces requirements in a product configuration to comply with the specified constraints.

When you enable Constraint Rules Engine in Product Configurator, any rules you created using Business Rules Engine no longer execute. But, you can export rules from Business Rules Engine and convert them to CML code. For more information, see Define Rules Engine with Transaction Processing Types and Convert Rules from Business Rules Engine into CML Code.

Note

To build a constraint model in CML, use this basic workflow.

  • Create global properties and settings that are header-level declarations in CML that define the foundational, fixed values for the entire constraint model. They’re crucial for setting up the core configuration environment and ensuring reusability across the model.
  • Create variables to define the properties or characteristics of a type. Variables can hold different kinds of data, such as strings, numbers, or lists, and can be calculated from other variables and values. In Revenue Management, variables represent product fields, product attributes, and sometimes context tags. See Create a Context Definition in Salesforce Help.
  • Define types, which represent entities or objects in the model. Types are the building blocks of CML. They’re similar to classes in object-oriented programming. In Revenue Management, types represent standalone products, bundles, product components, and product classes.
  • Define relationships that describe how different types are associated with each other. In Revenue Management, relationships represent the product structure in a bundle. For example, the root product has a relationship with its components.
  • Apply constraints to define logical restrictions, and enforce rules and conditions on types, variables, and relationships.

In Product Configurator, use the Visual Builder and CML Editor in Constraint Builder to create constraint models with CML.

See the linked topics for information on working with CML, including detailed code examples.

  • Modeling a Generator Set

    The Constraint Model for a Generator Set examples use CML to define a technical power configuration, illustrating concepts such as calculated variables, enforcement of external standards, and component selection based on requirements.

  • Core Concepts

    Constraint Modeling Language (CML) includes components that cover high-level global configurations to specific data types and constraints.

  • Core Concept Examples

    These examples illustrate core Constraint Modeling Language (CML) concepts including type, relationships, constraints, and so on.

  • Annotation Examples

    Constraint Modeling Language (CML) annotations are labels that you add to parts of a model, such as types, variables, relationships, and constraints. Annotations control how these elements are shown and how they behave in the configurator. Annotations help fine-tune the configurator and the constraint engine without changing the actual structure of the model.

  • Constraint Modeling Language (CML) Best Practices

    To prevent performance degradation or unexpected behaviors when the constraint engine executes CML code, follow these practices when writing code.

  • Business-Centric Constraint Modeling Language (CML) Guidelines

    Constraint Modeling Language (CML) must accurately calculate the total sum or aggregate of specific attributes like quantity or userCount across child components, especially in complex configurations requiring group-level aggregation

  • Debugging Constraint Modeling Language (CML)

    For optimal performance with CML, follow the performance guidelines and use debug logging to debug constraint models.

  • Model Structure

    The tables on the following pages show the structure for the constraint model in Core Concept Examples.