DMN Task
Handling complex business logic in one shape.
To perform complex business rules without extensive programming or complex if-else decision tree in the Process, DMN Task (Decision Model and Notation) can be used to simplify the implementation of these rule sets.
What is DMN Task?
Decision Model and Notation (DMN) Task can be used to perform business decisions and rules using easy to understand notation called DMN.
The DMN allows creation of decision models, where you specify the input variable, rules for the input, and results when a rule is matched. This is useful when different results can be obtained from a single or combination of input values, such as translating a numeric value for age to different age groups, or assigning a result value depending on different combinations of boolean input values. The rules can also result in multiple different values being returned for a single hit.

Usage
In order to use DMN Task, add it to your Process canvas and connect it as part of your Process using two Sequence flows. Like other Tasks, DMN Task must be connected between Trigger and a Return or a Throw shape, i.e. the Proces cannot start or end with a Task.
Once added to your Process, configure the shape's name and start filling your DMN decision table. You can choose the number of input and output values by pressing the plus symbols on corresponding columns, and then add rows for the rules by pressing the plus symbol on the last row of the table.

To set up an input or output value, double click on the column header to open the parameters for it.
Input values
The input value is specified in Expression field, where expressions from the chosen Expression language can be used in addition to values from the Process. In order to use reference values from the Process, note that the hashtag or number symbol is not used within DMN Task.
You can change the Expression language being used for creating the rules for this input value. By default, FEEL (Friendly Enough Expression Language) is used, as it is part of the DMN definition.
Input variable can be used in the rules to represent the input value. In the rule expressions, the variable defined in Input variable will contain the evaluated value of the Expression.
Finally, you can select the type of data being provided by the Expression.
Output values
For output values, you can only specify the name of the resulting value, and its data type. The result value will be accessible through #result reference value within field named by the output value's name.
Rules
Once necessary input and output values have been defined, you can start adding rules to your DMN decision table. The rules use syntax defined by the input's expression language selection. For example in FEEL, you can perform numeric evaluation and comparison by using expressions like below.
< 18 // Input value is less than 18
18 // Value is exactly 18
]18..65] // Value is above 18, and below or equals 65
1,2,3 // Value is 1, 2 or 3
not(5) // Value is anything but 5
Similar expressions also work for other data types. Also, instead of implicitly comparing the input value to a defined value, the input variable can be used in the expressions.
cellInput < 18 // Input value is less than 18
18 < cellInput <= 65 // Input value is between 18 and 65, or equal to 65
For each rule you specify, you also need a result value defined by the output. An optional comment is also possible in the Annotations field for each rule, explaining what happens in the rule.
You can also specify a rule hit policy, defining which result will be obtained in case more than one rule is fulfilled. This defaults to Unique, requiring the rules to always result in a single match. This can be adjusted to select the first rule to be fulfilled, or by the order the rules are presented on the table, as well as sum operations to combine multiple results into one.
Configuration
To set up a DMN Task, add the shape to Process canvas and connect it as part of your Process. After that, you can configure the parameters and DMN decision table for the shape.
The following configuration parameters are available for DMN Task.
Display name
Shapes can be given a display name in Frends Processes to distinquish them from each other. Shape's display name has no technical purpose and is only for documentational and visual purposes only. For shapes returning a #result reference value, the display name can be used to specify which result is meant.
Display name is given to the shape by double-clicking it on the canvas or through its configuration parameters.
Hit policy
Hit policy can be used to decide how to handle multiple matching rules from the DMN table.
Unique
Requires the ruleset to be defined so that there is always exactly one matching result. Results in an error if more than one result is obtained.
First
First rule to match will decide the output value. Rule evaluation order is from top to bottom.
Priority
Output values are assigned a priority value, and highest priority value will be chosen from the matched rules.
Any
More than one rule can result in the same output value, and any one of those can be returned because the result should be the same.
Collect
All results are returned as an unordered list or array of results.
Collect (Sum)
Sums the multiple matching results into one value.
Collect (Min)
Returns the smallest output value.
Collect (Max)
Returns the largest output value.
Collect (Count)
Returns the number of matched rules with distinct (unique) output values.
Input values
DMN decision table consists of one or more input values, that are evaluated by the rules in the decision table, to result in an output value.
Output values
DMN decision table consists of one or more output values, that are selected based on fulfilling the rule for each row, as well as by the hit policy if multiple hits occur.
Rules
Each row in the DMN decision table corresponds to one rule and corresponding output value. A rule condition is written for each input value, which then will result in the output value if the rules match. If multiple input values are used, conditions for all input values must be fulfilled to count as a hit.
Annotations
Comment field for each rule in the decision table, where you can explain what happens in that specific rule.
Expression
Provides the input value for the decision table to evaluate. Uses specified Expression language, such as FEEL, to create the input value from the provided expression.
In order to use variables from the Process, hashtag symbol is not used with the reference values like usual. Instead, reference values from Process are accessed like var.MyVariable or env.CRM.BaseUrl.
Expression language
Specifies the Expression language used for the input value and the rules. Defaults to FEEL (Friendly Enough Expression Language), which is part of the DMN definition.
Options available:
FEEL
JUEL
Groovy
JavaScript
Python
JRuby
Input variable
Name of the input variable that can be used in the rules to explicitly compare it against other values. The input variable will contain the input value that was evaluated from the Expression.
Type
Data type for the input and output values. Support for different data types is defined here by the expression language.
Options available:
string
boolean
integer
long
double
date
Predefined values
Predefined values can be added for each input and output field to be provided as input suggestions by the auto-complete feature when writing the rules.
Reference Values
DMN Task shape provides a #result reference value, which contains its operation's result values. Name of the output value specifies a field's name in the resulting object.
#result
#result reference value can be used to access earlier shape's return value. For Scope shapes, the value is specified using Return shape, while for Task's the #result is populated directly by the Task.

When Return shape is used to end Foreach or While shapes, the expression or HTTP content values in Return shape are available through #result reference value as an array of values for each iteration.
#result reference value by default references the last Task's or Scope shape's return value. Instead of unnamed #result reference, you can also use named #result reference value.
Named #result
Named #result reference value is used with square brackets, much like dictionary's or object's fields would be used, such as #result[Handle elements] or #result[HTTP Request]. This way it can be specified which shape's result you are using.
When using named #result reference value with Scope shapes and Return shapes, it should be noted that the #result reference value is named by the Scope shape and not by the Return shape, although the value is specified in the Return shape. Thus, when using the named #result value, such as #result[Handle elements], the Scope shape's name should be used.
Last updated
Was this helpful?