Context
A Context is a collection of key-value pairs, similar to a JSON object or a map. It is useful for simplifying complex decisions by breaking them down into intermediate calculations.
Structure
A Context consists of multiple Context Entries.
- Key: The variable name.
- Value: An expression (Literal, Decision Table, etc.) determining the value.
In the DMN spec, the last entry can be an optional Result expression — a context entry with no variable name. If present, the Context returns the result of that expression, if absent, the Context returns the map of all entries.
Example
Definition:
Principal: 100000Rate: 0.05Term: 30- Result:
Principal * (1 + Rate * Term)
FEEL Equivalent:
{
"Principal": 100000,
"Rate": 0.05,
"Term": 30
}
FAQ
What's the difference between a Context with a Result entry and one without?
A Context with a Result entry behaves like a small block of local variables ending in a final expression: it evaluates each named entry in order and returns the value of the Result expression (a context entry with no variable name in the last position). A Context without a Result entry returns the whole map of all entries as a FEEL context (key-value object). The engine evaluates both forms correctly, but the in-app modeler does not currently expose a UI for creating a Result entry — every entry added through the editor has a variable name. If you need a Context to return a single value, either author the DMN XML directly (or import it from a tool that supports Result entries), or use a Literal Expression that builds the value from named context references.
Can a Context entry reference earlier entries in the same Context?
Yes — each entry's expression is evaluated against a scope that includes every entry declared before it. So Annual: MonthlyIncome * 12, Total: Annual + Bonus works as expected: the second entry sees Annual defined above. Entries cannot reference themselves or later entries (the scope only contains entries above the current one), and duplicate keys within the same Context are rejected at evaluation with an error.
How is a DMN Context different from a JSON object?
Functionally they're the same shape — both are key-value maps. The differences are semantic: a DMN Context is evaluated (each value is a FEEL expression that the engine runs at decision time), entries are ordered and can reference earlier entries by name, an optional Result entry lets the Context produce a single value instead of the whole map, and a Context is a boxed expression so it can be the body of a decision or nested inside other boxed expressions. A JSON object is just data.