Constraint Modeling Language (CML) is how we write Product Configurator rules as code. A constraint model describes the products, their attributes and how they fit together. The Constraint Rules Engine compiles it and keeps every configuration inside its rules.1
This page reads the rule the launchpad already ships for the QuantumBit Complete Solution, then adds one of our own.
What it's for
The configurator has two rule engines. The Business Rules Engine runs rules built in the Visual Builder's rule templates. The Constraint Rules Engine runs a constraint model written in CML. When you turn the Constraint Rules Engine on for the configurator, rules built with the Business Rules Engine stop running. Salesforce lets you export them and convert them to CML.1
CML earns its keep when:
- A rule depends on several attributes at once: "Red Hat needs at least eight cores."
- A rule adds or removes products: "API Management at five or more needs Additional API."
- A rule reaches across bundles on the same quote: "API Access Requests needs a QuantumBit Database somewhere on the quote."
- The engine should find a valid value for you, not only reject a bad one.
You build a model in Constraint Builder, which has a Visual Builder and a CML Editor; both edit the same model.1
How it works
The parts of a model
In short: types are products, variables are their fields and attributes, relations are bundle structure, and constraints are the rules.
Salesforce's basic workflow has five parts:1
| Part | In Revenue Cloud it is | QuantumBit example |
|---|---|---|
| Global properties and settings | Header declarations for the whole model | extern string OriginalActionType, read from the context |
| Variables | Product fields, product attributes, sometimes context tags | Operating_System, Base_Core_Count |
| Types | Standalone products, bundles, components, product classes | type QuantumBitCompleteSolution : LineItem |
| Relations | The bundle's structure, root to components | relation additionalapi : AdditionalAPI |
| Constraints | The rules | constraint(...), require(...), message(...) |
The rules you can write
In short: constraint() keeps values logically consistent, require() makes products present, and a family of rule() and message() forms shows, hides, recommends and warns.
| Rule | What the engine does |
|---|---|
constraint(condition -> result, "message") |
Resolves the variables so the statement holds, or shows the message when it can't3 |
require(condition, target, "message") |
Adds the required product to the quote3 |
message(condition, "text", severity) |
Shows a banner: Info (gray), Warning (yellow) or Error (red)4 |
| Preference, setdefault and exclude rules | Prefer a value, default a component, or remove one2 |
rule(..., "recommend", ...), hide and disable |
Recommend a product, hide it, or keep it visible but unselectable2 |
| Table constraints | List the valid combinations of two or more attributes, row by row2 |
Constraints can use arithmetic, comparison and logic operators, including implication (->), bi-conditional (<->) and XOR (^). Implication binds loosest.2 The abort annotation on a constraint stops the search and fails the configuration when that constraint fails.2
Who set a value
In short: the engine never overrides a value the user set.
Every variable carries a cfgStatus: User (a person set it), Default (a setdefault or preference rule set it, and the engine may change it) or Engine (the engine set it to satisfy a constraint). Constraints skip variables a user set. If a rule must hold whatever the user picks, make sure no user-set value can conflict with it.2
Rules across bundles
In short: a virtual root type gives unrelated products a common parent, so one rule can see both.
A rule can only reach what its type can see. For rules between products with no parent and child link, Salesforce's pattern is a virtual type that is never sold and exists only as the configuration's root. Each product hangs off it as a relation, and the rule lives on the root.5 The launchpad's QuantumBitBundle model does exactly this with @(virtual = "true") type Quote, whose lineitems relation reads every line of the quote from the context.
How a model is stored and switched on
In short: a model is an expression set with usage type Constraint; the CML text lives on its version, and products are linked to types by separate records.
A constraint model is an Expression Set whose usage type is Constraint. Its CML text is stored on the ExpressionSetDefinitionVersion, in the ConstraintModel field. ExpressionSetConstraintObj rows tie the model to the catalog: each row points a product (or classification) at a type name in the CML, as a Type or a Port association. We read this from the launchpad's own constraint loader and its data on 2026-11-08.
Two things follow from that:
- Loading the text isn't enough. A bundle member needs its type and relation in the CML and its Type and Port rows. A product with a component row but no Type row shows in the bundle and then fails validation.
- An active version doesn't rebuild on its own. The launchpad deactivates and reactivates a version after uploading new CML, because uploading into an active version stores the text without rebuilding what the configurator runs. Salesforce documents the same cycle for constraint table data added after activation.
In the launchpad, only one QuantumBit model is active at a time: QuantumBitBundle, which merges the Complete Solution bundle rules with the quote-wide rules. Server2 is active beside it.
Build it
The launchpad's QuantumBitBundle model already carries two rules on the Complete Solution. The relevant part of the model:
type QuantumBitCompleteSolution : LineItem {
relation additionalapi : AdditionalAPI;
relation qbapimanagementsolution : QBAPIManagementSolution;
@(defaultValue = "Amazon Linux 2")
string Operating_System = ["Amazon Linux 2", "Redhat Enterprise Linux"];
@(defaultValue = "4")
int Base_Core_Count = [2, 4, 6, 8];
@(defaultValue = "0")
int Data_Utilization = [0, 10, 20, 30, 40, 5, 50];
constraint(Operating_System == "Redhat Enterprise Linux" -> Base_Core_Count == 8,
"When running RedHat Linux, a minimum of 8 Base Cores is required!");
require(qbapimanagementsolution[QBAPIManagementSolution] >= 5, additionalapi[AdditionalAPI]);
}
Reading it:
Operating_System,Base_Core_CountandData_Utilizationare the bundle's attributes. Each has a small, fixed domain and a default.- The
constraintuses implication. Choose Red Hat, and the engine setsBase_Core_Countto 8, unless you set the core count yourself, in which case you get the message. - The
requirecounts the API Management Solution components. At five or more, the engine adds Additional API.
Now our own rule: warn, without blocking, when data utilization reaches 40 percent. Add one line inside the type:
message(Data_Utilization >= 40, "At {} percent data utilization, plan database capacity before go-live.", Data_Utilization, "Warning");
A message rule takes the condition, the text, optional arguments that fill each {} in order, and a severity last.4 Warning lets the rep keep working but blocks the next step until they deal with it. We chose it over Error on purpose. An Error doesn't block someone working in the Transaction Line Editor anyway: they can still save the quote.4
To ship the change, edit the model in Constraint Builder's CML Editor (or upload the text to the version), then deactivate and reactivate that version. The lab does both.
Test and debug
There is no unit-test framework for CML. We test in the configurator, the only place that proves the running model changed. Reading the ConstraintModel field back only proves the text was stored.
Salesforce's performance guidelines for one evaluation:6
| Metric | Optimal | Marginal | Critical |
|---|---|---|---|
| Total execution time | under 100 ms | 100 ms to 1 s | over 1 s (10 s is a hard timeout) |
| Backtracks | under 1,000 | 1,000 to 10,000 | over 10,000 |
| Constraint violations | 0 | 1 to 100 | over 100 |
To see those numbers, turn on Apex debug logging at FINE and run the configuration. The log carries RLM_CONFIGURATOR_BEGIN, RLM_CONFIGURATOR_STATS and RLM_CONFIGURATOR_END sections, and the statistics section is where you look for the cause.6
The fixes Salesforce lists most often:7
- Keep domains and relationship cardinality as small as the business allows.
[0..99]makes the engine try a hundred counts. - Prefer integers to decimals and doubles: a double with two decimal places between 0 and 3 has three hundred values.8
- Replace long OR chains with one boolean variable the rules share.6
- Put calculations inside constraints, not inline in a variable.
- Leave pricing fields such as
ListPriceandNetUnitPriceout of CML: they aren't supported there.
Watch out
Turning the Constraint Rules Engine on stops every Business Rules Engine configurator rule. Export and convert those rules before you switch, not after.
A rule can't change a value the user set. If reps type a core count and your constraint wants another, they see your message; the engine won't overwrite them.
Uploading new CML into an active version doesn't change what the configurator runs. Deactivate and reactivate the version, then prove it in the configurator.
A product needs four things to be a working bundle member: its component row, its type and relation in the CML, and its Type and Port associations. Miss the associations and the failure looks like a product problem.
An Error message doesn't stop a rep in the Transaction Line Editor from saving the quote. If the rule must hold, enforce it with a constraint, not only a message.
Newer CML features change often. Group and ramp segment scope rules and the @productField product loader arrived in Summer '26; the quote guide's Newer than the exam section tracks them.
Sources
Every numbered note links to the Salesforce page it comes from. We read each on 2026-11-08.
- Revenue Management Developer Guide, Product Configurator: Constraint Modeling Language, Constraints, Require Rule vs Constraint, Message Rule, Virtual Quote Root, Best Practices and Debugging, read 2026-11-08
- Salesforce's rlm-base-dev launchpad, commit c77e638 (2026-10-08): the
QuantumBitBundlemodel, its data and its constraint loader, read 2026-11-08