Configure Contexts

A context is a collection of one or more key-value pairs with an optional result field. Each pair is called a context entry. The key attribute within a context entry acts as an identifier to its corresponding value attribute.

You can use a context to collectively document all decision logic related to a particular scenario or entity. Say you need to determine the loan eligibility of an applicant, based on the applicant’s net monthly income and expense. For this purpose, you can create a decision named Loan Eligibility using the context notation and add expressions or logic for gross monthly income, monthly expense, and net monthly income. Then, you can add a result field (within the context) that evaluates the net income and expense for the loan eligibility, or you can choose to evaluate these within another decision.

Without a result field, a context decision returns multiple key-value pairs as output. In this case, you can invoke any context entry from another decision. If you add a result field, the output of this field is displayed as the context’s output. Here, you can only invoke the context’s result from another decision.

To add a context decision to the canvas and define its properties, see Add Decisions.

Follow these steps to configure the decision's logic:

  1. Double-click the context node to access its logic editor.
    Alternatively, select the node, and click Edit or View Decision Logic icon on the sidebar.
  2. Add entries to the context.
    1. Click Add Entry to create a new context entry. A key-value pair is created.
    2. In the Key field, enter a unique name or label.
    3. Configure the logic for the Expression (value) field. This field has the expression notation selected by default.
      1. To change the logical notation for the value field, click Options icon in its row, select Change Value, then select a different notation from the available options.

        Note:

        If you add a function as one of the context entries, the context as a whole doesn’t return a result. However, you can invoke results of individual context entries throughout the decision model.
      2. Configure the logic for the selected notation. You can use input variables or built-in functions to define the logic.
    4. Similarly, add as many entries to your context as needed.
    5. Use the Drag Drag icon control to reorder the context entries.
  3. Optionally, add a result for the context.
    1. Click Add Result.
      A result field is created with the expression notation selected by default.
    2. To change the logical notation for the result field, click Options icon in its row, click Change Value, then select a different notation from the available options.
    3. Configure the logic for the selected notation.
  4. Additionally, you can move or replicate a logical notation and its contents between fields. Click Options icon in a field and select the required action.
  5. To reuse the entire logic definition in another decision, cut or copy it and paste it into the desired decision. Click Options icon in the header and select the required action.
  6. To delete a field, click Options icon in its row and click Delete.
Changes you make within the decision model are automatically saved and validated. Errors and warnings, if any, are displayed in the editor. Click the error or warning icon to review and fix them. See Review and Fix Errors in a Decision.

A context decision with a result

The following image shows a context with a result field that determines the loan eligibility of applicants.

The output of the result field is the context’s output. In this case, the context returns a true or false regarding an applicant’s loan eligibility. You can reference the context’s result in other decisions within the model using the context name (for example, Loan Eligibility).

The image shows a decision called Loan Eligibility created using the Context notation with a result field. There are three context entries, and each context entry has a Key field and an Expression field. For the first entry, Gross Income is entered in the Key field and 10000 is entered in the Expression field. For the second entry, Expenses is entered in the Key field and 5000 is entered in the Expression field. For the third entry, Net Income is entered in the Key field and Gross Income - Expenses is entered in the Expression field. For the final entry, that is the Result field, Net Income > Expenses is entered.

A context decision without a result

The following image shows a context without a result field and an expression decision referencing multiple context entries to determine the loan eligibility of applicants.

The output of this context is a list containing results of all three context entries. To reference a particular context entry from another decision, use the format ContextName.EntryKey (for example, Income.Expenses). Within a context, an entry can only reference entries that are above it.

  • A context without a result:
    The image shows a decision called Income created using the Context notation without a result field. There are three context entries, and each context entry has a Key field and an Expression field. For the first entry, Gross Income is entered in the Key field and 10000 is entered in the Expression field. For the second entry, Expenses is entered in the Key field and 5000 is entered in the Expression field. For the third entry, Net is entered in the Key field and Gross Income - Expenses is entered in the Expression field.
  • An output decision calling context entries:
    The image shows an Expression decision called Loan Eligibility. The value entered in the expression field is: Income.Net > Income.Expenses.