7 Dictionary Output from Decision Tables
alicia pritchett edited this page 2022-03-21 10:09:16 -04:00

Decision tables can output multiple values, if you have multiple columns.

Normally, this results in unique, independant variable names for each column. However, you can output a dictionary, with columns as keys in the dictionary.

For instance, instead of a decision table that ouput name='Mona' and breed='Aussie', you could output a dictionary {'name': 'Mona', 'breed': 'Aussie'}

Decision Table

In the first column, the Output Name is set to dog.name

Decision Table First Column

In the second column, the Output Name is set to dog.breed

Decision Table Second Column

Notice that the Decision Id is set to Decision_Dog.

Workflow Model

In the Business Rule Task, set the Decision Ref to the Decision Id in the decision table. In this case, it is Decision_Dog

Business Rule Task

You can now access the output as a Python dictionary, using the dot notation we provide.

This example outputs the data in Element Documentation. You could also access it in a Script Task.

Using the output

Using Decision Tables to describe Workflow and Category Status

You can use DMN tables to hide workflows and categories, as well as set additional properties on workflows.

To do this, you need a DMN table alongside the top level workflow. I will use a category for this example.

First, the ID of the table needs to match the ID of the category. Here, the category ID is 'irb_submission'.

Setting the DMN ID

Next, the DMN table should be populated with conditions that describe state. This is a simple example where a category is always hidden- the expression is if 1==1 and the only output tested is True. Set the expression and conditions in the first column.

Double-click on the second column (category is... box) and set the correct status output. In this case, it would be irb_submission.status. Generally, to set the status, it would be workflow_id.status or category_id.status.

You can optionally set a message to display as well. Add a third column and set the message with worklow_id.status or category_id.status. This is especially helpful for giving users a tip about workflows in disabled or required states.

For workflows, the possible states are hidden, disabled, required, and optional.

For categories, the possible state is just hidden.

Example DMN table

Finally, the DMN table should be added to the top level workflow. The implementation is set to DMN, and the decision ref is the same as the DMN ID (and category ID).

Adding to TLW