Access Quantity in CML: Cardinality and Attribute Constraints
There are two ways to access quantity in CML. Use cardinality constraints and attribute constraints correctly for best performance.
There are two ways to access quantity in CML:
A cardinality constraint creates or validates the presence of components. The constraint engine adds or removes instances to satisfy the conditions of the constraint.
An attribute constraint, such as lineItemQuantity or ItemEndQuantity, only reads or validates. The constraint engine validates the expression, but doesn’t configure to satisfy the conditions of the constraint
For best performance, follow these guidelines:
- Use a cardinality constraint whenever possible. Use
lineItemQuantityorItemEndQuantityonly when a cardinality constraint can’t meet the business need. - Treat
lineItemQuantityandItemEndQuantityas read-only. Use only in calculation or evaluation rules. - Keep scope in mind. When a product can have multiple instances, read
lineItemQuantityorItemEndQuantityper instance. Avoid reading the attribute at a parent or aggregate scope where it can be unbound or ambiguous. - Don’t use
lineItemQuantityorItemEndQuantityto create components. Drive component creation by cardinality, not by attribute references.
Use constraint patterns similar to these examples. Do this.
Avoid this.
Do this.
Avoid this.