External Variables

External variables are global Constraint Modeling Language (CML) variables defined within a virtual CML type.

See virtual in Type Annotations. The values for external variables are usually set by the environment that launches the constraint solver engine. Use external variables to import runtime data from the context header (such as Quote or Sales Transaction) into the configuration model, with the contextPath annotation to denote header fields, or with tagName annotation to denote lineItem fields. See External Variable Annotations section.

If the external variable isn’t mapped to any external data source, it must have a default value. Otherwise, it may remain unbound and cause errors.

Here’s a basic declaration syntax.

In this example, the constraint engine needs access to the quote header (Sales Transaction) field, which defines the shipping location to enforce region-specific compliance requirements. The contextPath annotation is used to map the field (SalesTransaction.ShippingCountry) to an external CML variable (ShippingCountry).

The CML variable name can be different from the context path value.

See the full example in Using ContextPath and tagName annotations.

Here are the details of external variable annotations.

AnnotationPossible ValueDescription
contextPath”SalesTransaction.<ST_FIELD>”, where the sales transaction field is pulled directly from the context definition.References sales transaction values directly from their context definition, such as account name, sales transaction total, or address. The contextPath annotation can only be used for header fields. To create a variable linked to a SalesTransactionItem, use the tagName annotation to reference context tags on SalesTransactionItem within a type. See tagName in Variable Annotations.