Context

The Context button on the Decision Logic Subribbon opens the context boxed expression.

context 1

A context contains a numbered list of context entries. In a decision, the list of context entries immediately follows the decision name.

context 2

In a BKM, the list of parameters is shown above the context entries.

boxed context

Each context entry has a name in the first column and a value expression in the second column. The value expression may be any boxed expression type, even another context.

Below the numbered context entries is a single column containing a literal expression, known as the final result box. The meaning and use of a context depends on whether or not an expression exists in the final result box.

Context with a Final Result Box Expression

If the final result box contains an expression, that expression determines the output value of the context. The context entries in that case are local variables referenceable only within the context, not from outside. A context entry (or the final result box) may reference, in addition to any inputs in scope to the decision or BKM, the names of any preceding context entries. In the figure above, for example, the final result box references the context entries Monthly Repayment and Monthly Fee. The local variables defined by the context entries simplify the literal expressions used in the context without adding supporting decisions to the DRD.

This is crucial with BKMs, for example, since their decision logic must be a single value expression, not a DRD fragment. A context with final result box allows complex BKM logic, such as Installment Calculation above, to be broken apart into relatively simple expressions, all within a single value expression.

Context with No Final Result Box Expression

A context with nothing in the final result box has completely different usage and meaning. Here each context entry defines a component of the output, a structure. As with a final result box expression, the value expression of a context entry may reference preceding context entries – here, for example, Price after discount references Price before discount – and value expressions may be other than literal expressions, e.g. a decision table. But the important thing about a context with no final result box expression is that it creates a data structure, here one with 5 components. The context entries are part of the output. For example, other decisions can reference the total price as Invoice.Total Price.

contextnofinalresult 1536x1436

Function Definition

In the value expression of a context entry, the Decision Logic Subribbon includes a Function button that creates a function definition.

functiondeficon 1200x350

A function definition is like a BKM except that it is a context entry, not a DRG element. Like a BKM, its definition includes parameters and a value expression, and it may be invoked only by a subsequent context entry or final result box.

functiondef

For example, the function definition isMissing returns true if parameter val is either null or whitespace.