DMN Examples for Decision Modeling
DMN Examples for Decision Modeling
CREATED WITH
Table of Contents
Decision Requirements diagram showing a Decision with a Business Knowledge Model and a number of inputs
including another Decision.
Once these models have been defined, simulated and tested by the business, technologists and engineers can then refine
these models and automatically generate software artifacts including programming code directly from the models
reducing the possibility of errors of interpretation and reducing the time to implementation.
What is DMN?
DMN is intended to provide a bridge between business process models and decision logic models:
· Business process models will define tasks within business processes where decision-making is required to occur
· Decision Requirements Diagrams will define the decisions to be made in those tasks, their interrelationships, and
their requirements for decision logic
· Decision logic will define the required decisions in sufficient detail to allow validation and/or automation
(c) Sparx Systems 2024 Page 4 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Taken together, Decision Requirements diagrams and decision logic allow you to build a complete Decision Model that
complements a business process model by specifying - in detail - the decision-making carried out in process tasks.
DMN provides constructs spanning both decision requirements and decision logic modeling.
· For decision requirements modeling, it defines the concept of a Decision Requirements Graph (DRG) comprising a
set of elements and their connection rules, and a corresponding notation: the Decision Requirements Diagram
(DRD).
· For decision logic modeling it provides a language called FEEL for defining and assembling Decision Tables,
calculations, if/then/else logic, simple data structures, and externally defined logic from Java and PMML into
executable expressions with formally defined semantics.
Modeling decision-making processes using DMN allows you to record, specify and analyze complex decision processes
as a system of interrelated decisions, business rules, data sets and knowledge sources. By doing so, you can decompose a
highly complex decision making process into a network of supporting decisions and input data. This facilitates easier
understanding of the overall process, supports refactoring of processes and simplifies the task of validating the process,
by allowing you to easily validate the individual steps that make up the overall process.
When you build a Decision Model in Enterprise Architect using DMN, you can run simulations of the model to verify
the correctness of the model. After you have verified your model, you can generate a DMN Module in Java, JavaScript,
C++ or C#. The generated DMN Module can be used with the Enterprise Architect BPSim Execution Engine,
Executable StateMachine, or within a separate software system that you are implementing.
Enterprise Architect also provides a 'Test Module' facility, which is a preprocess for integrating DMN with BPMN. The
aim is to produce BPMN2.0::DataObject elements, then use these to verify that a specified target decision is evaluated
(c) Sparx Systems 2024 Page 5 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
correctly with the DMN Module. You then configure BPSim by loading DataObjects and assigning DMN Module
decisions to BPSim Properties.
This feature is available in the Unified and Ultimate Editions of Enterprise Architect, from Release 15.0.
The DMN decision requirement model consists of a Decision Requirements Graph (DRG) depicted in one or more
Decision Requirements Diagrams (DRDs). The elements modeled are decisions, areas of business knowledge, sources of
business knowledge, input data and decision services.
A DRG is a graph composed of elements connected by requirements, and is self-contained in the sense that all the
modeled requirements for any Decision in the DRG (its immediate sources of information, knowledge and authority) are
present in the same DRG. It is important to distinguish this complete definition of the DRG from a DRD presenting any
particular view of it, which might be a partial or filtered display.
(c) Sparx Systems 2024 Page 6 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Getting Started
Decision Model and Notation (DMN) is a standard published and managed by the Object Management Group (OMG).
Portions of this topic have been used verbatim or are freely adapted from the DMN Specification, which is available on
the OMG DMN web page ([Link] A full description of the DMN and its capabilities can be
found on the OMG website.
The purpose of DMN is to provide the constructs that are needed to model decisions, so that organizational
decision-making can be readily depicted in diagrams, accurately defined by business analysts, and (optionally)
automated. It is also intended to facilitate the sharing and interchange of Decision Models between organizations.
Enterprise Architect partitions the tool's extensive features into Perspectives, which ensures that you can focus on a
specific task and work with the tools you need without the distraction of other features. To work with the Decision
Model and Notation features you first need to select this Perspective:
Example Diagram
An example diagram provides a visual introduction to the topic and allows you to see some of the important elements
and connectors that are created in specifying or describing the way decisions are modeled. The Decision Requirements
diagram will introduce elements such as Decision Tables, Knowledge Sources, Input Date and more. Much of the power
of Enterprise Architect relies in the ability to simulate or 'run' the decision models and to predict outcomes based on
different data sets. This functionality will be described in later topics but starts with the creation of a Decision
Requirements diagram.
This topic introduces you to the most important elements that you need to create Decision models. This includes the
creation of a Decision Requirements diagram which describes how decision are related and what inputs each decision has
potentially including other decisions. You will learn about the mst important elements including: Decisions. Business
Knowledge Models, Input Data Items Definitions, Data Set and Decision Services.
This topic introduces you to the main concepts of the language including its structure, architecture and the elements and
connectors that are used to create Decision Model and Notation (DMN) models. Understanding the intent and structure
of the language will help analysts create meaningful and productive decision models.
Enterprise Architect allows Decision models to be run (simulated) which allows you to visualize the outcomes of
(c) Sparx Systems 2024 Page 7 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
decisions. In addition to this core facility you can also integrate the Decision models with BPSim which is a simulation
engine for the simulation of BPMN diagrams. In this topic you will a number of different ways to integrate DMN with
BPSIm.
In this topic you will learn the process of integrating a DMN Model with a UML Class element. The DMN Module can
be integrated with a UML Class element, so the code generated from that Class element can reuse the DMN Module and
be well-structured
This topic describes how to import a DMN XML file from a different Enterprise Architect repository or another DMN
compliant tool. One of the promises of open standards is the ability to share models between different tools. Enterprise
Architect often becomes the tool of choice for modeling because of the breadth of features and standards it supports. This
allows Decision model to be related to Strategy, Requirements, Business Processes, Software Implementation elements
and more.
More Information
This section provides useful links to other topics and resources that you might find useful when working with the
Decision Model and Notation tool features.
(c) Sparx Systems 2024 Page 8 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Example Diagram
Imagine you are an Airline reservation officer working at the check-in counter for a busy domestic airline. Getting the
aircraft off on-time is critical as delays can result in fees applied by the airport controllers, needing to fly at a lower
altitude increasing the cost of fuel, and other penalties.
A message from the supervisor appears on your screen saying that the economy cabin is overbooked; you will need to
upgrade some passengers to Business or First Class — but which passengers should be chosen and which cabin should
they be upgraded to? A decision needs to be made but what factors should be considered? This can be recorded in a
Decision Model using a Decision Requirements diagram.
This is helpful but the busy check-in officer would still need to weigh up all the factors and make an unbiased decision.
Should a disgruntled passenger be given priority over a Gold level frequent flyer, or should the fact that a particular
passenger is connecting to an international flight take precedence. These 'rules' can all be recorded in a Decision Table,
making it clear which passengers should get an upgrade and to which cabin: Business or First Class. This will make it
much easier to make the decision and the rules can be formulated, agreed upon and checked for consistency back at head
office. In this example we have kept it simple and used two factors: firstly the number of flights the passenger has made
in the last month and secondly how overbooked the cabin is.
The table is divided into columns and rows. There are three types of column: inputs that are required to make the
decision, outputs that are the result of applying the rules, and annotations.
This is again very helpful but still requires the busy check-in officer to be able to source all the required information
required to find the right row in the Decision Table. Even if all this information were available, a wrong decision could
still result from human error in selecting the wrong row in the table.
Fortunately the Decision Models can be automated and generated to programming code that can be executed by an
application. So our busy check-in officer would not need to do anything or make any decisions; as he or she was
checking in the passengers, if a particular passenger was entitled to an upgrade it would be visible on the computer
screen. In the next diagram the model has been simulated so that the business and technical staff can agree that the model
has been defined correctly. Any number of user-defined data sets can be used to test the model before generating the
programming code that will run in the check-in system and display the result to the end user.
(c) Sparx Systems 2024 Page 9 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
When developing the models a business or technical user can step through the simulation and the system will show that
user which row in the Decision Table was fired to determine the output. This is very useful in models that are made up of
multiple decisions.
It is common for the rules that govern the upgrade decision to change. For example, the Marketing Department might
decide they want to reward passengers that travel on long-haul flights. The Decision Requirements diagram can be
altered to include the new input, the Decision Table modified, and the programming code regenerated. Once the changes
have been pushed through to the airport systems, the right passengers will be automatically upgraded. The check-in
officer could still view the Decision Tables during a training and briefing session to understand the rules.
(c) Sparx Systems 2024 Page 10 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
These steps will guide you through the creation of a simple Decision Requirements Diagram (DRD). In this example, we
will create the model from scratch, rather than using a pattern from the Model Builder.
Step Description
3 Using the diagram toolbox, place a Decision element on the diagram. Choose
'Invocation' as the type - we will use this element to 'invoke' a decision from a
Business Knowledge Model element. Name the element 'Determine Cabin for
Upgrade'.
5 Place another InputData element on the diagram. Name this element 'Cabin Status'.
6 Place a Business Knowledge Model element on the diagram. Choose the type
'Decision Table'. Name this element 'Cabin Upgrade Policy'.
(c) Sparx Systems 2024 Page 11 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
We can now specify the details for each of the elements making up this model.
By double-clicking on the Business Knowledge Model element 'Cabin Upgrade Policy', the 'DMN Expression' window is
displayed, showing an empty Decision Table. This is where we will define the rules of our cabin upgrade policy.
By default, new Decision Tables are created with two input columns and one output column, a header row and three
empty rules rows.
The left-most column in the table displays the Hit Policy and also numbers the rules. By default, the Hit Policy is 'U' for
'Unique'. This is the policy that we will use for our example, so you do not need to change this column heading.
For more information on Hit Policies, refer to the Decision Table Hit Policy Help topic.
Name and Define Types for Decision Table Inputs and Outputs
Step Description
1 On the toolbar of the 'DMN Expression' window, click on the 'Edit Parameters'
button, .
The 'Edit Parameters' dialog displays.
2 Replace the parameter name 'Input 1' with 'Num of Pax Overbooked'.
If necessary, click on the 'Type' drop-down arrow and set the type of this parameter
to 'number'.
3 Replace the parameter name 'Input 2' with 'Num of Flights in Last Month by Pass'.
Set the type of this parameter to 'number' as well.
Close the 'Edit Parameters' dialog.
(c) Sparx Systems 2024 Page 12 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
5 Right-click on the column 1 expression and check that its data type is set to
'number'.
7 Right-click on the column 2 expression and set its data type to 'number'.
Once you have finished editing the rules, click on the Save button .
(c) Sparx Systems 2024 Page 13 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Finally, click the Validate button , to check for errors in the table of rules.
Add two ItemDefinition elements to the diagram, one for each of the InputData elements. Name one element
'CustomerDefinition' and the other 'CabinStatusDefinition'.
Double-click the ItemDefinition named 'CustomerDefinition' to edit the definition. The DMN Expression window is
displayed.
Right-click on the cell 'CustomerDefinition' and choose 'Add Child Component'. Overtype the name of the child
component with 'Num of Flights in Last Month' and overtype its datatype with 'number'. Click the 'Save' button to save
the changes, and close the window.
Similarly, double-click on the ItemDefinition named 'CabinStatusDefinition', add a child component named 'Num of Pax
Overbooked' and set its data type to 'number'. Save the changes and close the window.
Select the InputData element 'Customer'. In the Properties window, select the property 'typeRef' and click on the
button.
(c) Sparx Systems 2024 Page 14 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
The 'correctness' of your decision model can be tested, by running simulations using a range of representative data sets to
verify that the model produces the correct result in all situations.
You can create numerous Data Sets with various names, using a range of data values. You can set one of the data sets as
the default value.
We will now create a Data Set for each of our InputData elements.
Step Description
(c) Sparx Systems 2024 Page 15 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
2
In the DMN Expression window, click on the 'Edit Data Set' button .
The 'Edit Data Set' window is displayed.
3
Click on the button.
A new data set is created.
5 Repeat for the InputData 'Cabin Status'. Enter a value of, for example, 4.
Locate the DMN 'Simulation Configuration' Artifact in the Diagram Toolbox. Drop one of these onto the diagram as
well.
Double-click on it to open the DMN Simulation window at the 'Simulate' tab.
From the DMN Simulation window, you can run simulations of the completed Decision Model. You can also perform
validation, generate code and generate test modules.
Step Description
4 The body of the window now displays the InputData elements and the decision
results that are available as inputs to the selected decision.
Click on the Save button.
5 Use the 'Value' column to select one of the predefined DataSets for the InputValues,
then you can click on the 'Run' button in the lower toolbar to run a
simulation, using the selected data sets.
(c) Sparx Systems 2024 Page 16 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
This table summarizes the notation for all components of a Decision Requirements diagram.
Component Description
Decision A Decision element denotes the act of determining an output from a number of
inputs (Input Data or Decision), using decision logic expressed as Literal
Expressions, Decision Tables, Invocations or Boxed Context.
Business Knowledge A Business Knowledge Model denotes a reusable module of decision logic
Model represented by a function, which includes zero, one or more than one parameter.
Decision Service A Decision Service can enclose a set of reusable decisions that are invoked
(expanded) internally - for example, by another Decision or Business Knowledge Model - or
externally - for example, by a BPMN Process.
A good practice is to use a diagram to describe a single expanded Decision Service.
Decision Service If a Decision Service element serves as an invocable element, connected with
(collapsed) knowledge requirements to other elements with invocation logic, we can hide the
details of the Decision Service to focus on the decision hierarchies in the big
picture.
Input Data An Input Data element denotes information used as an input to one or more
Decisions.
Item Definition An Item Definition is used to define the type and structure of data items used in the
decision model. It is primarily referenced by Input Data elements as a basis for the
type and structure of data expected to be input. It can also be referenced for setting
the structure for an output.
The Item Definition contains Data Sets that provide sets of values useful when
performing varied simulations.
Knowledge Source A Knowledge Source element denotes an authority for a Business Knowledge
Model or Decision.
Information Requirement An Information Requirement denotes Input Data or Decision output being used as
input to a Decision.
Knowledge Requirement A Knowledge Requirement denotes the invocation of a Business Knowledge Model
or Decision Service.
Authority Requirement An Authority Requirement denotes the dependence of a DRG element on another
DRG element that acts as a source of guidance or knowledge.
(c) Sparx Systems 2024 Page 17 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
(c) Sparx Systems 2024 Page 18 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Detailed explanations of the DMN Expression Editor's features for each element and expression type are provided in the
child Help topics of this topic.
Access
Value Expressions
Summarized in this table are four distinct types of value expression with references to the Help topics detailing each of
them.
Decision Table A Decision Table is a tabular representation of a set of related input and output
expressions, organized into rules indicating which output entry applies to a specific
set of input entries.
Literal Expression A Literal Expression specifies the decision logic as a textual expression that
describes how an output value is derived from its input values. To support
simulation and execution, the Literal Expression can use JavaScript functions.
(c) Sparx Systems 2024 Page 19 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Boxed Context A boxed context is a collection of context entries, consisting of (name, value) pairs,
each with a result value.
The context entries provide a means of decomposing a complex expression into a
series of simple expressions, providing intermediate results that can be used in
subsequent context entries.
Element Description
ItemDefinition ItemDefinition elements are used to define data structures and, optionally, to
restrict the range of allowable values of the data. ItemDefinitions can range from a
simple single type through to a complex structured type. ItemDefinitions are used
to specify the type of InputData elements as well as input parameters.
(c) Sparx Systems 2024 Page 20 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Decision Table
A Decision Table is a tabular representation of a set of related input and output expressions, organized into rules
indicating which output entry applies to a specific set of input entries.
Decision Tables are supported by both the Decision and the Business Knowledge Model element types. They are denoted
Access
Overview
This image shows the DMN Expression window as it appears for a Decision Table.
(c) Sparx Systems 2024 Page 21 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
The Decision Table should contain all the inputs - and only those inputs - required to determine an output.
In determining which rules are applied, the expressions defined in the Input Clauses are evaluated for the given inputs
and the expression results are then used to find rules with matching input entries.
Where the DMN Expression window is not wide or deep enough to display all columns and rows, you can use scroll
bars to access the hidden content, or drag the borders out to increase every column width. The 'Input' and 'Output' column
widths are initially the same, but you can adjust each column width independently of the others, by dragging the column
border either within the table or in the gray bar just below the tab names.
When a Decision Table is selected, the features available in the DMN Expression window are accessed via the Toolbar at
the top of the window, as shown:
For more details refer to the Toolbar for Decision Table Editor Help topic.
Parameters
In the case of Business Knowledge Model (BKM) elements, parameters are used to pass input values supplied by the
invoking element. The BKM's decision logic is evaluated using the input parameters and the result is returned to the
invoking element. By default, a BKM element is created with two input parameters, 'Input 1' and 'Input 2'.
Click on the icon in the toolbar of the DMN Expression window to display the 'Edit Parameters' dialog.
Here you can change the parameter names, re-arrange the sequence, set their data types, create additional parameters or
delete existing ones.
Hit Policy
(c) Sparx Systems 2024 Page 22 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Right-click on the 'Hit Policy Indicator', then choose the desired Hit Policy from the pop-up menu. The various Table Hit
Policies are described in detail in the Decision Table Hit Policy Help topic.
Input Clauses
An Input Clause of a Decision Table is defined as an expression. Very often, the expression is simply an unmodified
input value; however, it could also be an expression involving more than one input value or it could be defined as a
conditional statement, such as 'Application Risk Score > 100'. The allowable values apply to the expression result rather
than the input values used and, as such, the type of the values should match the type of the expression result.
Decision Tables are created with two default Input Clauses, 'Input 1' and 'Input 2'. The data type for both of these clauses
is 'number'. In the DMN Expression window, the Input Clauses are displayed as column headings on the Decision Table.
To modify an Input Clause, click on the column heading to select the cell, then click again or press F2 to edit.
Auto-completion is supported when editing Input Clauses. That means, for Decision elements, any inputs that are
connected to the Decision element are made available for selection from a list. Similarly, for Business Knowledge
Model elements, the invocation parameters are made available for selection from a list. See the DMN Expression
Auto-completion Help topic for further information.
To add additional columns of input entries to the Decision Table, click on the icon on the toolbar of the DMN
Expression window.
To remove input columns from the table, right-click within the unwanted input column, then select the option 'Delete
Input Column' from the pop-up menu.
The order of the input columns in the table can be re-arranged by dragging and dropping columns to new positions.
(Drag the unlabelled cell at the very top of the table column to the required position.)
Allowed Values
When defining an 'Input' or an 'Output' column, the second row of the column defines the Allowed Values. This is an
optional cell in the column, but useful for clarifying the entries in the rows beneath it. When running a validation, each of
the cells below the Allowed Values cell are checked to make sure they conform to the expression in this cell.
The expressions used in this cell depend on how the 'Input' or 'Output' column is typed. For example:
· Number - [18 ..35]
· String - 'High', 'Low', 'Medium'
· Boolean - true, false
· Undefined - '-'
Fast Fill Allowed Values
The Input/Output Expression that this references can be a simple value or a complex FEEL expression; however, if it is
directly related to an ItemDefinition's 'Allowed Values' field then pressing the Spacebar will enable a fast-fill option to
set the 'Allowed Values' as defined in the ItemDefinition (usually referenced via an InputData element).
(c) Sparx Systems 2024 Page 23 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
For more details see the Help topic DMN Expression Auto Completion.
Output Clauses
An Output Clause consists of a name, a data type and an optional list of allowed values. To modify an Output Clause,
click on the column heading cell to select the cell, then click again or press F2 to edit.
To add additional columns of output entries to the Decision Table, click on the icon on the toolbar of the Expression
editor window.
To remove Output columns from the table, right-click within the unwanted Output column, then select the option 'Delete
Output Column' from the pop-up menu.
The order of the columns in the table can be re-arranged by dragging and dropping columns to new positions. (Drag the
unlabelled cell at the very top of the table column to the desired position.)
For the simulation to work it is critical to set the data type for all Input and Output Clauses. Range, gap and overlap
validations are supported for clauses of type 'number', but validation cannot be performed if the type has not been
specified. Code Generation for typed languages such as C++, C# and Java requires that the data types are specified.
When the data type is specified as 'string', there is no need to enclose each string literal within quotes. String values are
displayed using italic font if the type has been declared.
To set the data type, right-click on the Input or Output column header and select the required type from the list.
(c) Sparx Systems 2024 Page 24 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Decision Table rules are defined by specifying input entries and corresponding output entries within the cells of a table
row. For 'number' data types, input entries can be specified as a single value, or as a number range, such as '<10', '>100'
or '[2..8)'. (When defining number ranges, the use of round brackets indicates that the bounding number is NOT
included; use of square brackets indicates the bounding number is included.) Output entries should specify a single value
per cell.
Additional rules can be appended to the list of rules by clicking on the icon in the toolbar. Unwanted rules can be
deleted from the table by right-clicking on the rule and selecting the option 'Delete Rule Row' from the pop-up menu.
Existing rules can be copied and pasted within the table by first selecting the rules, (use 'Ctrl+Click' to add/remove from
selection), then using the menu options 'Copy Rules to Clipboard' and 'Paste Rules from Clipboard' to perform the copy
and paste. The copied rules can then be modified by selecting and editing individual cell entries.
If the 'Allowed Values' field is set for a string or Boolean expression, the Spacebar can be used to display a list of values
to select from, as shown in the earlier Allowed Values - Fast Fill Rows section.
Rules can also be sorted within the table, either by:
· Clicking the icon on the toolbar, then choosing to either 'Sort By Input' or 'Sort By Output', or
· Right-clicking on individual rules within the table and selecting the 'Move Rule Up' or 'Move Rule Down' option
from the pop-up menu
To determine which table rows are selected for output, the expressions that are defined by the Input Clauses are
evaluated for the given inputs and the results of the expressions are then compared against the input entries of the table
rows. Where the expression results match the input entries of a table row, that row is selected for output.
The Decision Table's 'Hit Policy' determines how the table's matching rows are then used to produce its output.
Rule Formats
You can select - using a Toolbar icon - to display the Decision Table in one of three formats, as shown here.
Rule-as-Row format, where the rule is developed along rows with the inputs, outputs and annotations set in columns:
(c) Sparx Systems 2024 Page 25 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Rule-as-Column format, where the rules are developed down columns with the inputs, outputs and annotations set along
the rows:
Rule-as-Crosstab format, where the rules are formed from inputs defined as a set of rows AND a combination of
columns, with outputs set in the intersecting cells. (Note that this format hides the 'Annotation' fields):
At the end of a simulation, in a Crosstab Decision Table, related input entries and output entries are highlighted. For
example, in this simulation processing resulted in the output of a 0.10 discount for a Business Customer where Order
Size was less than or equal to 10 and delivery was not applicable.
Crosstab Settings
In Rule-as-Crosstab format, as the inputs form both rows and columns and the outputs are at the intersections, the steps
for setting values are slightly different from those for the other two formats.
1. To add another type of input, right-click on the input column header and select the 'Add Input' option. You are
prompted to enter the input name; the input is added as a set of fields under the current column fields.
To delete an input type from the columns, right-click on its set of fields and select the 'Delete Input' option. The
name of the input and its set of fields are removed from the column headings.
2. To add another type of output, right-click on the Output block in the top left of the window and select the 'Add
Output' option. You are prompted to enter the Output name; the name is added to the Output block and a new row is
added to each cell in the body of the window.
To delete an Output type, right-click on the type name in the Output block in the top left of the window and select
the 'Delete Output' option. The Output name and its fields in the grid are removed.
3. You can rotate between the input types to select one for the row headers. Right-click on the row and click on the
'Select Input as Row Header' option. This displays a list of the input types; click on the type to use as the row
header; the other types are combined in the columns.
(c) Sparx Systems 2024 Page 26 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
4. To add a value entry row or column to the inputs, right-click on a current row or column and select the 'Add Input
Entry Row' or 'Add Input Entry Column' option, as appropriate. A prompt displays for the name of the input entry;
when you enter this, the appropriate row or column is added to the Decision Table.
To delete a value entry row or column, right-click on it and select the 'Delete Input Entry Row' or 'Delete Input
Entry Column' option. The selected row or column is deleted from the table.
5. In the Input columns, each row matches a type of input. If you want to move the row for one type of input above or
below another, right-click on it and select the 'Move Input Up' or 'Move Input Down' option. The context menu only
provides the options that can be actioned, so as it is not possible to move, say, the last row downwards, the 'Move
Input Down' option is not listed.
(c) Sparx Systems 2024 Page 27 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Toolbar Options
Icon Description
Toggle the view for the Decision Table between Rule-as-Row, Rule-as-Column and
Rule-as-Crosstab. Alternatively, click on the drop-down arrow and select the format
you require.
Click on 'Sort By Input' to sort the rules by input columns; click on 'Sort By Output'
to sort the rules by output columns. The columns can be dragged and dropped to
organize the sorting order.
Merge cells of adjacent rules, where the content of the input entries is the same.
You can edit the content of the merged cells. During simulation, the merged items
are highlighted.
Display the 'Edit Parameters' window, where you can specify the names and data
types of the parameters that are passed when invoking the decision logic of a
BusinessKnowledgeModel element.
Append an annotation column (with a green heading cell) to the table, in which you
can record short notes or comments on the rule. (See the illustrations in the
Rule-as-Row/Rule-as-Column row earlier.) You can add more than one annotation
column if required, typing in an appropriate column title in each heading cell.
To remove an annotation column, right-click on it and select the 'Delete Annotation
Column' option.
Show or hide the allowed values fields for the 'Input' and 'Output' columns.
The allowed values defined for an input or output will be used for validation and
auto completion editing.
(c) Sparx Systems 2024 Page 28 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
(c) Sparx Systems 2024 Page 29 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
The 'Unique' Hit Policy is the most popular type for a Decision Table and all rules are disjoint.
(c) Sparx Systems 2024 Page 30 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
In a table with the 'Priority' Hit Policy, multiple rules can match, with different output entries. This policy returns the
matching rule with the highest output priority.
Note: The list of allowable values is used to define the output priority. Here, the allowable values are listed as
INELIGIBLE and ELIGIBLE; INELIGIBLE is defined as having a higher priority than ELIGIBLE.
One possible simulation result might resemble this:
The matching rules are highlighted, but the output from rule 2 is chosen because INELIGIBLE has higher priority than
ELIGIBLE.
For a Decision Table with the 'Collect-Sum' (C+) Hit Policy, the result of the Decision Table is the sum of all the distinct
outputs.
(c) Sparx Systems 2024 Page 31 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
(c) Sparx Systems 2024 Page 32 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Access
DMN Expression Window Simulate > Decision Analysis > DMN > DMN Expression : Validate button
DMN Simulation Window Simulate > Decision Analysis > DMN > Open DMN Simulation > Configure :
Validate button
It is good practice to define 'allowed values' for the Input Clauses and Output Clauses of a Decision Table. The 'allowed
values' list is used to perform range-checking of the input and output entry values for the table rules.
In this example:
(c) Sparx Systems 2024 Page 33 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
· The 'Age' Input Clause defines a range of [20..120]; however, the input entry for rule 1 specifies a range of [18..21];
this is outside the range of allowed values, so rule 1 is reported as invalid
· The 'Marital Status' clause defines its allowed values as an enumeration of 'S, M'; rule 12 specifies a value of 'D',
hence that rule is also reported as invalid
These issues can be corrected, either by updating the 'allowed values' or by modifying the input entries for the invalid
rules, depending on the actual business rules.
The gaps in rules for a Decision Table mean that, given a combination of input values, no rule is matched. This indicates
that some logic or rule might be missing (unless a default output is defined).
When the Decision Table contains many rules that specify number ranges, it becomes difficult to visually detect gaps and
quite time-consuming to compose and run exhaustive test cases.
For example:
The validation reports a gap in the rules. Closer inspection reveals an error in rule 9. The input entry (580..600], should
be [580..600].
When rules overlap, for a given combination of input values, multiple rules are matched. This is a violation if the
Decision Table specifies its Hit Policy as 'Unique'.
When the Decision Table contains many rules that specify number ranges, it becomes difficult to visually detect gaps and
quite time-consuming to compose and run exhaustive test cases.
For example:
(c) Sparx Systems 2024 Page 34 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
The validation reports an overlap in the rules, involving rules 4 & 5. Closer inspection reveals the overlap exists in the
third input 'Credit Score', where '<610' overlaps with '[600..625]'. You could correct this issue either by changing rule 4
to '<600' or by changing rule 5 to '[610..625]', to reflect the actual business rules.
(c) Sparx Systems 2024 Page 35 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Literal Expression
A Literal Expression is the simplest form of DMN expression; it is commonly defined as a single-line statement, or an
if-else conditional block. The Literal Expression is a type of value expression used in both Decision elements and
Business Knowledge Model (BKM) elements. As the expression becomes more complex, you might prefer a Boxed
Context or, in order to improve the readability, you can encapsulate some of the logic as a function in the DMN Library.
The icon on the top right corner of the Decision or BKM element indicates that it is implemented as a Literal
Expression.
Access
Overview
This image shows the DMN Expression editor window, as it appears for a Literal Expression.
The Literal Expression is a textual representation of the decision logic. It describes how an output value is derived from
its input values, using mathematical and logical operations.
The expression editor window presents the Literal Expression as a table, with two key rows:
· Parameters: defines the input parameters used in the expression
· Literal Expression: where the formula for the expression is defined - this defines the output of the Decision
In order to support simulation and execution, the literal expression can use JavaScript global functions or JavaScript
object functions. Users can also create DMN Library functions for use within the expressions.
When a Literal Expression is selected, the layout of features accessible in the DMN Expression window is:
(c) Sparx Systems 2024 Page 36 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
For more details refer to the Help topic Toolbar for Literal Expression Editor.
In accordance with the Friendly Enough Expression Language (FEEL) language specification, parameter names can
contain spaces, which makes the expression easier to read. Enterprise Architect also provides Intelli-sense support for
editing the expressions, allowing for minimal typing and fewer mistakes.
Given a decision hierarchy such as the one shown, when editing the expression for 'Decision1', the inputs to 'Decision1' -
namely 'Decision2', 'Decision3', 'InputData1' and 'InputData2' - will be available through Intelli-sense in the editor.
By right-clicking on the 'Expression' row of the DMN Expression window, then choosing the menu option 'Edit
Expressions...', the expression code editor dialog is displayed. Pressing Ctrl+Space displays the Intelli-sense menu:
(c) Sparx Systems 2024 Page 37 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
· For 'Decision' elements, all of the inputs to the decision will be displayed
· For Business Knowledge Model (BKM) elements, all of the input parameters will be displayed
The DMN Model can be generated as source code in JavaScript, Java, C# or C++; since some languages might have
different syntax for some expressions, Enterprise Architect provides language override pages for each language. If no
override code is specified for a language, the expression defined for the FEEL language will be used.
In the generated code, the space inside a variable name will be replaced by an underscore.
(c) Sparx Systems 2024 Page 38 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Toolbar Options
This table provides descriptions of the features accessible from the toolbar in the DMN Expression window when a
Literal Expression is selected.
Options Description
Click on this button to edit parameters for the Business Knowledge Model.
(c) Sparx Systems 2024 Page 39 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
· The runtime parameter value will be displayed; for example, Rate = 00.005
· The BKM's result will be evaluated by the literal expression and the value is displayed on the declaration line; for
example, return = 1798.65
Although the formula for this can be written in one line, it is quite complicated. We can re-factor this model with Built-In
function and Boxed Context to improve readability:
· The Boxed Context defines two variable-expression paired entries; these variables serve as 'local variables', which
can be used in later expressions
· Return value: the expression can use the value of 'local variables'
· Any expressions in a Boxed Context can use built-in functions that are defined in the customizable Template —
DMN Library; for example, functions PMT(...) and decimal(...) are used in this example
The simulation result is exactly the same as a Literal Expression:
(c) Sparx Systems 2024 Page 40 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
(c) Sparx Systems 2024 Page 41 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Boxed Context
A Boxed Context is a collection of context entries, presented in the form of a table, followed by a final result expression.
These context entries consist of a variable paired with a value expression and can be thought of as intermediate results.
This allows for complex expressions to be decomposed into a series of simple expressions, with the final result being
evaluated in a much simpler form.
The Boxed Context type is supported in both the Decision and the Business Knowledge Model element types. It is
Access
Overview
This image shows the DMN Expression editor window as it appears for a Boxed Context expression.
A Boxed Context is a collection of context entries, presented in the form of a table, followed by a final result expression.
Each context entry consists of a variable and a value expression. The variable can be considered as an intermediate
result, and it can be used within the value expression of any subsequent context entry. The value expression of a context
entry can be either a Literal Expression or an Invocation, and can make use of any available inputs such as parameters (to
a BKM element), InputData or decision results, as well as any previously defined context variables.
The final result of a Boxed Context expression is determined by working through each context entry in turn, evaluating
the value expression and assigning its result to the variable, then finally evaluating the result expression. The result
expression can also make use of any input or local variable, but must evaluate to provide a result.
When a Boxed Context expression is selected, the layout of features accessible in the DMN Expression window is:
(c) Sparx Systems 2024 Page 42 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
For more details refer to the Help topic 'Toolbar for Boxed Context Editor'.
Specifying Parameters
In the case of BusinessKnowledgeModel elements, parameters are used to pass input values supplied by the invoking
element. The BKM's decision logic is evaluated using the input parameters and the result is returned to the invoking
element. By default, a BKM element is created with two input parameters, 'Input 1' and 'Input 2'.
Click on the icon in the toolbar of the DMN Expression window to display the 'Edit Parameters' window.
Here you can change the parameter names, set their data types, create additional parameters or delete existing ones.
(c) Sparx Systems 2024 Page 43 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
You can also edit the value expression by entering text directly into the expression cell.
For further information on how to specify Literal Expressions or Invocations, please see the Help topics covering those
subjects.
(c) Sparx Systems 2024 Page 44 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Toolbar Options
Options Description
Display the 'Edit Parameters' window, where you can specify the name and data
type of each parameter that is passed when invoking the decision logic of a
BusinessKnowledgeModel element.
Create a new context entry and append it to the list of context entries.
Move the currently selected context entry up one position in the list.
Move the currently selected context entry down one position in the list.
This button is enabled when a Decision Table is defined for a Business Knowledge
Model element.
Select the 'Input Parameter Values for Simulation' tab, complete the fields, then
click on this button. The test result will be presented on the Decision Table, with
the runtime values of inputs and outputs displayed and valid rule(s) highlighted.
You can use this functionality to unit test a BusinessKnowledgeModel element,
without specifying its context.
A number of menu options are available for this tool bar button. For more
information, see the Help topic Simulate DMN Model.
(c) Sparx Systems 2024 Page 45 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
The Business Knowledge Model (BKM) Installment calculation is implemented as Boxed Context.
· The BKM defines four parameters: Product Type, Rate, Term and Amount
· The Boxed Context defines two variable-expression pair entries; these variables serve as 'local variables' that can be
used in later expressions
· Return value: The expression can use the value of 'local variables'
· Any expressions in a Boxed Context can use built-in functions, which are defined in the customizable Template —
DMN Library; the functions PMT(...) and decimal(...) are used in this example
In general, the expression and variables do not have to specify a type, which is inferred from the value provided. This
feature is supported generically by JavaScript, which is used for Enterprise Architect's DMN Simulation.
However, if you want to generate code from a DMN model to compiled languages such as Java, C++ or C#, you will
have to specify the type for each Context Entry Variable. Otherwise, if you validate the model, you will see warnings
such as:
Right-click on the Context Entry Variable (Monthly Fee, Monthly Repayment) in this model.
(c) Sparx Systems 2024 Page 46 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Now type in the variable type, appending it to the variable name and separated by a colon, as shown here.
(c) Sparx Systems 2024 Page 47 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Then click on the Save button on the toolbar to save the expression, and click on the button to validate the model
again.
The parameter and Context Entry's variable name can contain spaces, according to the FEEL language specification. This
feature makes the expression easy to read. In order to help you edit the expressions with less typing and making fewer
mistakes, Enterprise Architect provides Intelli-sense support for editing expressions:
To edit an expression, right-click on the expression (in the right-hand field) and select the 'Edit Expressions' menu
option. The 'Expression' dialog displays. Click on the required line and press Ctrl+Space to show the Intelli-sense menu:
(c) Sparx Systems 2024 Page 48 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
· All the Context Entry Variables earlier than the current one will be included (the Context Entry Variables later than
the current one are excluded)
· For a Business Knowledge Model (BKM), all the parameters will be included
· For a Decision, all the required Decisions will be included
The DMN model can be generated as source code for JavaScript, Java, C# and C++. Since some languages might have
different syntax for some expressions, Enterprise Architect provides language override pages for each language. If no
override code is specified for a language, the expression defined for the FEEL language will be used.
In the generated code, the space inside a variable name will be replaced by an underscore.
Select the 'Input Parameter Values for Simulation' tab and complete each field.
Click on the Save button and then on the Simulation button on the toolbar; the test result will be presented in the Boxed
Context expression.
· The runtime parameter value will be displayed; for example, 'Rate = 0.00375'
· The 'Context Entry' variable's runtime value will be displayed; for example, 'Monthly Repayment = 1520.06'
· The Business Knowledge Model (BKM)'s result will be evaluated by the last entry and the values displayed on the
declaration line; for example, 'return = 1540.06'
You can use this functionality to unit test a BKM without knowing the context so that later on it can be invoked by a
Decision or another BKM.
(c) Sparx Systems 2024 Page 49 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Boxed List
A DMN Boxed List is a Decision element that contains a list of boxed expressions. These items are arranged as a vertical
list in the DMN Expression window.
A Boxed List is often used in conjunction with a for loop expression that is contained in a related Decision element. The
for loop expression is used to iterate over each row in the Boxed List, binding the List's Element-field to the
corresponding variable, and evaluating the expression in the scope. The output of the for loop is a list containing the
evaluation of the expression for each individual iteration.
Access
Diagram Toolbox Drag a Decision element or BKM element from the Toolbox onto a DMN diagram,
and select 'List' from the pop-up expression menu.
Double-click on the DMN element; the DMN Expression window is displayed,
showing details of the selected element.
Properties Right-click on a DMN Decision or BKM element on the diagram, and select the
'Properties | Properties' menu option.
On the General page, select the 'Tags' tab, and in the 'expressionType' value field
click on the drop-down arrow and select 'List'. Click on the OK button.
Double click on the DMN element; the DMN Expression window is displayed,
showing details for the selected element.
Overview
It is common for Boxed Lists to be used as Enumerations, where all List items are of the same type.
It is also common for Boxed Lists to be used as a collection of data, where each item might have a different type.
(c) Sparx Systems 2024 Page 50 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
The DMN Expression window has a toolbar providing the options 'Add New List Item', 'Delete Existing List Item' and
'Move Item Up or Down'.
Right-click on a List item to display context menu options for setting the List item's type - string, number, boolean or
object.
In this example, we have three Decisions: Rank, Suit and Rank Suit Combination
(c) Sparx Systems 2024 Page 51 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
· Decision Rank is represented as a Boxed List with 13 Items from 'A' through to 'K'
· Decision Suit is represented as a Boxed List with 4 Items: 'Club', 'Diamond', 'Heart' and 'Spade'
· Decision Rank Suit Combination is represented as a Literal Expression with a for loop: for r in Rank, s in Suit return
s+r
When multiple iteration contexts are defined in the same for loop expression, the resulting iteration is a cross-product of
the elements of the iteration contexts. The iteration order is from the inner iteration context to the outer iteration context.
In this example, the cross-product of Rank (13 items) and Suit (4 items) is a list of 13 * 4 = 52 elements.
(c) Sparx Systems 2024 Page 52 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Relation
A DMN Decision Relation element provides a convenient shorthand method for defining a list of related values in a
DMN diagram. A Decision Relation is like a relation table with columns and rows. The header of the grid displays the
name of each column. Each row displays the set of values for the corresponding columns.
Access
Alternatively, you can change an existing DMN Decision or BKM element to a Decision-Relation type. To do this:
· Right-click on a DMN Decision or BKM element on the diagram, and select the 'Properties | Properties' menu option
· On the General page, select the 'Tags' tab, and in the 'expressionType' value field click on the drop-down arrow and
select 'Relation'; click on the OK button
Overview
The DMN Relation Decision-type is a vertical list containing rows of values. A key to using the Decision Relation is the
means to iterate through the rows of values using a For Loop. The For Loop can be defined in, say, a related Literal
Expression Decision as a formula to process the rows in the Decision-Relation element.
The DMN Expression window has a toolbar providing options to add a new row, delete an existing row and move the
selected row up or down.
You can also:
· Drag the grid header to reposition columns.
· Right-click on the header cells to display the context menu options for setting the column's Type to: 'string',
'number', 'boolean' or 'object'.
In this example, we have two Decisions - 'Loan Table' and 'Monthly Payment List' - and one Business Knowledge Model
- 'Payment'.
(c) Sparx Systems 2024 Page 53 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
'Loan Table' is a Decision implemented as a Relation with four columns: 'Loan', 'Principle', 'Term' and 'Annual Rate'.
'Monthly Payment List' is a Decision implemented as a Literal Expression with a for loop:
(c) Sparx Systems 2024 Page 54 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
On simulation, the runtime values show in the Simulation window and on the diagram beside the element; you can click
on a step to see the simulation process.
(c) Sparx Systems 2024 Page 55 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Invocation
An invocation is a container for the parameter bindings that provide the context for the evaluation of the body of a
Business Knowledge Model. There are two common use cases for an Invocation:
· Bind an Input Data to the Business Knowledge Model
· Bind parameters or context entry variables to the Business Knowledge Model
An example of each is provided in the sub-topics of this Help topic.
Access
Overview
An Invocation is a type of value expression applicable to both Decision elements and Business Knowledge Model
elements. It is a tabular representation of how decision logic defined within an invocable element (a Business Knowledge
Model or a Decision Service) is invoked by a Decision or by another Business Knowledge Model.
When an Invocation is selected, a number of facilities for working on it are accessible from the toolbar of the DMN
Expression window:
For more details refer to the Help topic 'Toolbar for Invocation Editor'.
Bindings
The parameter bindings of an Invocation provide the context for evaluation of the body of the invocable element.
(c) Sparx Systems 2024 Page 56 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
In this example:
· The Decision 'Post-bureau risk category' is represented as an Invocation connecting to the Business Knowledge
Model 'Post-bureau risk category table', implemented as a Decision Table
· The Decision 'Post-bureau risk category' is the target of three Information Requirement connectors from two Input
Data elements and one Decision element
· The binding list binds the input values to the Business Knowledge Model's parameters
· The Invocation also specifies the requested 'OutputClause'; in the case where a Decision Table has multiple Output
Clauses defined, the Invocation must explicitly request an Output Clause as the result of the expression
Inputs
Inputs from other Decisions and InputData elements can be set by pressing the Spacebar in the field:
(c) Sparx Systems 2024 Page 57 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Output
As an Invocation can only invoke one Business Knowledge Model, the output is defined by the Business Knowledge
Model output.
(c) Sparx Systems 2024 Page 58 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Toolbar Options
This table provides descriptions of the features accessible in the DMN Expression window when an Invocation is
selected.
Options Description
Click on this button to edit parameters for the Business Knowledge Model.
This button is enabled when the Invocation is defined for a Business Knowledge
Model.
Select the 'Input Parameter Values for Simulation' tab, complete the fields and click
on this button. The test result will be presented on the Decision Table, with the
runtime values of inputs and outputs displayed and valid rule(s) highlighted.
You can use this functionality to unit test a Business Knowledge Model without
knowing the context and later on invoked by a Decision or other Business
Knowledge Model.
Menu options are available for this toolbar button. For more information, see the
(c) Sparx Systems 2024 Page 59 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
(c) Sparx Systems 2024 Page 60 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
In this example, Input Data Applicant Data is typed to Applicant data Definition, which has three components.
The Business Knowledge Model Application risk score model is implemented as a Decision Table with three inputs and
one output.
The Decision Application risk score is implemented as an Invocation to bind the Input Data's 'leaf' components to the
BKM's parameters.
(c) Sparx Systems 2024 Page 61 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
In order to make the binding easier, Auto-Completion is supported for the binding expression.
The full modeling and simulation instructions are available in the Pattern's documentation.
(c) Sparx Systems 2024 Page 62 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
In this example, the Business Knowledge Model (BKM) Difference Of Two Squares is implemented as Boxed Context:
· The variable sum of ab is implemented as an invocation by binding parameters a and b to BKM Addition
· The variable difference of ab is implemented as an invocation by binding parameters a and b to BKM Subtraction
· The variable difference of squares is implemented as an invocation by binding local variables sum of ab and
difference of ab to BKM Multiplication
In order to make the binding easier, auto-completion is supported for the binding expression.
The full modeling and simulation instructions are available in the Pattern's documentation.
(c) Sparx Systems 2024 Page 63 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
To help you edit expressions with less typing and fewer mistakes, Enterprise Architect provides Intelli-sense support for
editing the expressions.
Note that the parameter and Context Entry variable names can contain spaces, according to the FEEL language
specification. This feature is intended to make each expression easy to read.
Examples
Given this decision hierarchy, the expression in 'Decision3' is able to use the outputs from the two referenced Decisions.
(c) Sparx Systems 2024 Page 64 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Language selection
The DMN Model can be generated as source code in JavaScript, Java, C# or C++. As the syntax differs between the
(c) Sparx Systems 2024 Page 65 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
languages, Enterprise Architect provides language-override pages for each language. If no override code is specified for
a language, the expression that is defined for the FEEL language will be used.
Note: In the generated code, the space inside a variable name will be replaced by an underscore.
(c) Sparx Systems 2024 Page 66 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Access
DMN Expression Window Simulate > Decision Analysis > DMN > DMN Expression : Validate button
DMN Simulation Window Simulate > Decision Analysis > DMN > Open DMN Simulation > Simulate :
Validate icon
Common Validations
In this example, the Boxed Context Business Knowledge Model BKM1 defines two parameters, 'Input 1' and 'Input 2',
and two local variables, 'Local Variable 1' and 'Local Variable 2'. The expression has been validated, and the results
output to the 'DMN Validation' tab of the System Output window.
(c) Sparx Systems 2024 Page 67 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
· Context Entry #1 failed because there is a typographic error; it should be operator '-', but the user typed or copied in
'–'
· Context Entry #2 failed because there is no space between 'Input' and the number 2; note that the function 'ceiling()'
is defined in the DMN Library so it can be successfully parsed
· Context Entry #3 failed because there is no space between 'Local' and 'Variable'
It is hard to visually identify these kinds of error. Running validation can help identify errors and then you can easily
perform a correction.
Dependency Validation
A decision might require other decisions, input data and business knowledge models; these relationships are identified by
InformationRequirement and KnowledgeRequirement connectors.
When the graph is getting complex, it is quite possible that some connectors are missing or the wrong connector type is
being used.
In this example, click on the Validate button, Enterprise Architect will show that:
· 'Decision3' is used by 'Decision1' by binding to a parameter of the called BKM2; however, it is not defined - an
InformationRequirement connector is missing
· The Invocation defined in 'Decision1' is not valid; the connector type from 'BKM2' to 'Decision1' should be a
KnowledgeRequirement
After fixing these problems, run the validation again:
(c) Sparx Systems 2024 Page 68 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
The idea is to define allowed value enumerations in ItemDefinition, then compose a list for selection whenever these
values are requested.
In this example, ItemDefinition 'Applicant data . Employment Status' defines an enumeration of allowed values.
When editing values for the InputData typed to this ItemDefinition, press the Spacebar on the keyboard to display a list
of values to select from.
We could also define multiple data sets for the InputData, as the Auto Completion feature is available on this dialog.
(c) Sparx Systems 2024 Page 69 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
We can quickly fill the 'Allowed Values' field for a Decision Table by selection:
(c) Sparx Systems 2024 Page 70 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Information Requirement
On a decision hierarchy, a decision might access required decisions and input data; these required elements form a list of
variables that can be used by the decision.
(c) Sparx Systems 2024 Page 71 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
In this example, Decision 'Eligibility' requires two decisions - 'Pre-bureau risk category' and 'Pre-bureau affordability' -
and one Input Data item 'Applicant data'.
When setting the binding values for the invoked BusinessKnowledgeModel 'Eligibility rules', an Auto Completion list
will prompt for selection. In this list, there are sub-decision names - leaf components of the input data. With this feature,
you can easily set up an invocation.
(c) Sparx Systems 2024 Page 72 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Simple Decision Requirements diagram showing three inputs into a Decision using a Decision Table.
The logic of the decision is described using a number of devices but the most commonly used and accessible form is the
Decision Table. The Decision Table contains rows and columns like a spreadsheet and covers all the possible
combinations of inputs to produce a number of outputs. For example if an applicant is older than 21 and younger than 65
and earns $60,000 per year with a good credit rating the bank will lend them $300,000 for a home loan.
A Decision Table showing three inputs and one output, rows would be added to define the rules.
(c) Sparx Systems 2024 Page 73 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Decision
A Decision element is used to evaluate an output based on one or more inputs. The logic that determines the output is
either defined within that Decision element or it invokes the decision logic contained in a Business Knowledge Model
that is connected to the Decision.
Inputs
A Decision can have any number of inputs, including the option to define the input values in the element. The most
common input is to use an Input Data Element.
Output
A Decision can have zero or one output. The output can be a complex data set.
Value Expressions
The output of a Decision element is determined using a Value Expression. The Value Expression contains the element's
decision logic and can take one of four forms: Decision Table, Literal Expression, Invocation or Boxed Context. Value
Expressions are defined and edited using the DMN Expression editor, which displays one of four formats according to
the type of expression being used.
When displayed on a diagram, the Decision element shows an icon in the top-right corner that indicates which type of
value expression it is using.
Type Description
(c) Sparx Systems 2024 Page 74 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Unless a BKM is working on fixed values, it usually requires defining a set of input parameters, as well as the definition
of an output. The parameters and the decision logic are defined using the DMN Expression window.
When used in a decision model, a BKM must be connected via a KnowledgeRequirement to a Decision or another BKM,
through which it receives its inputs . The input parameters are defined using the icon. These can be set as a simple
type or a complex type defined using an ItemDefinition. The naming of the input parameters influences the naming
within the Value Expression.
Output
A BKM output is via a KnowledgeRequirement which must be an input to a Decision or to another BKM. The output is
defined using:
Value Expressions
To define a means for evaluating an output, based on the decision logic, a Business Knowledge Model (BKM) element
(c) Sparx Systems 2024 Page 75 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
contains a Value Expression. This is defined and edited using the DMN Expression window, which has four formats, the
format being determined by the type of Value Expression that you want to use.
The BKM element can be set with these structures for the Value Expression. Each is shown in the model with an icon.
Type Description
To ensure a BKM element is able to produce a correct output it can be validated using the Validation icon . A BKM
can also be tested as a unit to ensure it is operative using the Simulation button. For more details see the Input
Parameter Values for Simulation Help topic.
(c) Sparx Systems 2024 Page 76 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
BKM Parameters
A Business Knowledge Model (BKM) is implemented as a function definition, with parameters and a DMN expression
as its body (such as Decision Table, Boxed Context or Literal Expressions).
As a BKM is intended to function stand-alone, and be called by Decisions or other BKMs, it is necessary to define any
input parameters. Also, for Literal Expressions, you must define the output parameter.
When defining any input Parameters you can set them with default values for testing. After creating a BKM, to verify
that it functions correctly, you can run a simulation based on these default values.
To open the 'Edit Parameters' dialog, in the DMN Expression window, click on the Edit Parameters button :
Note: this is an example for a Literal Expression that includes a return type.
Edit Parameters
Action Description
Modify the name of the existing parameter by in-place editing in the cell.
Click on the Type to enable a drop-down. Select a type for the parameter from the
(c) Sparx Systems 2024 Page 77 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
drop-down.
Set an Item Definition Type
When changing the type of Parameter there is an option to select a pre-defined type
from an ItemDefinition. The option for this is 'Select Type ...'. When this option is
selected it will open a dialog for selecting an ItemDefinition.
(c) Sparx Systems 2024 Page 78 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Parameters for a BKM are accessed from the DMN Expression window, using the Edit Parameters button on the
toolbar:
A default set of values for these parameters, that can be used in a simulation of the BKM, are defined in the 'Input
Parameter Values for Simulation' tab on the DMN Expression window:
With these parameters set the BKM can be tested using the Simulation button.
Simulation Examples
These are two examples of using the Input Parameter Values for Simulation.
Type Description
(c) Sparx Systems 2024 Page 79 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Decision Table An example simulation of a BKM Decision Table element based on values set in
the Input Parameter Values for Simulation tab.
Literal Expression An example simulation of a BKM Literal Expression element based on values set in
the Input Parameter Values for Simulation tab.
(c) Sparx Systems 2024 Page 80 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Double-click on the 'Eligibility rules' element to open the BKM in the DMN Expression window
When a Decision Table is created for a Business Knowledge Model, we can test this BKM by binding some values:
Click on the Simulation button on the tool bar to obtain this result:
(c) Sparx Systems 2024 Page 81 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
· The runtime parameter value will take the place of 'Allowed Values' in simulation mode
· Valid rule(s) are highlighted
· Since this Decision Table's Hit Policy is P (Priority) the final result is determined by the order of Output Values;
since 'INELIGIBLE' and 'ELIGIBLE' are the output values and 'INELIGIBLE' comes ahead of 'ELIGIBLE', rule #3
will give the final result and this applicant is 'INELIGIBLE'.
(c) Sparx Systems 2024 Page 82 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Double-click on the 'Payment' element to open the BKM in the DMN Expression window.
Similar to a Decision Table, the Business Knowledge Model implemented as a Boxed Expression can be tested as well.
Take the 'Payment' element as an example. This BKM will calculate the monthly repayment based on interest rate,
number of terms and principal amount.
We could provide test values such as these:
Click on the Simulation button on the tool bar; this result is obtained:
The runtime parameter and return values will be displayed with an equals sign '=' followed by the runtime value. This
value is also displayed as a label against the element on its parent diagram.
(c) Sparx Systems 2024 Page 83 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
In this example, given an annual Rate of 4% for 30 years and a principal of $300,000, the monthly repayment is
$1,432.25.
Note: The DMN Library already has a PMT function defined; this example mainly demonstrates how Literal Expression
works and how to test it with a set of arguments.
(c) Sparx Systems 2024 Page 84 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
InputData
An InputData element is used to input into Decisions a set of values that originate outside the model. That set of values is
used for evaluating Decisions. It derives its type and a set of values from an ItemDefinition.
Overview
InputData elements are created by dragging an icon from the Toolbox onto a DMN diagram.
The name of the InputData element must be unique and not duplicate the name of any other Decision, InputData,
Business Knowledge Model, Decision Service, or Import in the decision model.
Referencing an ItemDefinition
The structure of the data, as well as sets of values for an InputData element, are defined in an ItemDefinition element. A
DMN InputData element must be referenced (typed) by an ItemDefinition by either:
· Clicking on the icon on the DMN Expression window of the InputData element or
· Selecting the InputData element and pressing Ctrl+L to select the ItemDefinition from the dialog
InputData properties
The properties of an InputData element are accessible via the DMN Expression window. Double-click on the InputData
element to open this window.
The DMN Expression window provides a view of the data structure as well as access to Data Sets that can be used in
simulations.
(c) Sparx Systems 2024 Page 85 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Access
Ribbon Simulate > Decision Analysis > DMN > DMN Expression, then select / create an
InputData
Toolbar Options
Option Description
Opens the ItemDefinition element that is referenced by this InputData as its type
definition.
Option to select a Data Set as defined in the ItemDefinition that references this
InputData.
Opens the dialog for editing data sets for this input data. Each InputData can define
multiple data sets. With this feature, the DMN Simulation can quickly test the
results of a decision by choosing different data sets.
(c) Sparx Systems 2024 Page 86 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Auto Completion
If the InputData has a field with 'Allowed Value' defined, then the field can be populated by selecting the field, pressing
on the Spacebar, then selecting an option from the drop-down.
Data Sets
Data Sets are defined in the ItemDefinition referenced by the InputData element. Using the toolbar drop-down you can
select a data set from the ItemDefinition. Once a set is selected you can alter the values of the items. You can also add
new Data Sets by opening the Edit Data Set window using the icon.
(c) Sparx Systems 2024 Page 87 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
ItemDefinition
Fundamental to creating Decision Models is the definition of the structure of data items used within the model. An
ItemDefinition is used to define the structure of the input data and, optionally, to restrict the range of allowable values of
the data. ItemDefinitions can range from a simple single type through to a complex structured type.
Overview
ItemDefinition elements are created by dragging a icon from the DMN Toolbox page onto a
DMN diagram.
The core properties of an ItemDefinition element are accessed via the DMN Expression window.
Access
Ribbon Simulate > Decision Analysis > DMN > DMN Expression, then select or create an
ItemDefinition
This image is an overview of the DMN Expression window, showing a complex data item and the layout of the key
fields used in the definition of the data. Included is a view of a Data Set defined using this ItemDefinition. A Data Set is
an 'instance' of data conforming to an ItemDefinition, which contains a set of values to be used in the DMN simulation.
(c) Sparx Systems 2024 Page 88 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
As ItemDefinitions are foundation elements in the model, it is recommended that they are validated before going on to
use them in the model. This will ensure that any issues are resolved early on in the process of creating a complex model.
For more details on setting up ItemDefinitions, see these Help topics:
· DMN Item Definition, Data Set and Input Data
· Types of Component
· ItemDefinition Allowed Value
· DMN Expression Auto Completion
· DMN Expression Validation
(c) Sparx Systems 2024 Page 89 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Toolbar Options
Option Description
Opens the 'Edit Data Set' dialog, in which you can create and edit 'instances' of the
ItemDefinition for use by InputData elements.
(c) Sparx Systems 2024 Page 90 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
ItemDefinition Structure
A complex ItemDefinition consists of nested elements. For example, tApplicantData is structured as:
The tApplicantData ItemDefinition example is a composite type of five child items. 'Monthly' is composed of three
children (Expenses, Income and Repayments). The Leaf components (non-composite), will have a primitive type such as
number, string or Boolean.
Data Set
The ItemDefinition's Data Set can be viewed and edited using the icon on the Toolbar. With the 'Edit Data Set'
dialog, you can add, delete and duplicate the data sets. There is also support for CSV import and export of data sets.
(c) Sparx Systems 2024 Page 91 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
As shown in the example, the ItemDefinition for tApplicantData defines three data sets:
· default
· Income4000
· Income5000
Each data set can be viewed in an InputData element that is typed to the ItemDefinition. For example the 'Applicant Data'
InputData element is typed to the 'tApplicantData' ItemDefinition. The DMN Expression window for 'Applicant Data',
illustrated here, shows the data values according to the data set selected in the drop-down list in the window toolbar
(Income5000 in this case).
(c) Sparx Systems 2024 Page 92 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
(c) Sparx Systems 2024 Page 93 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Types of Component
An ItemDefinition element can be defined as a tree of components that consists of only one of either:
· A built-in type or
· A Composition of ItemDefinition elements
In this tree of components, if a component is a 'leaf' that has no child components, it must be set as a built-in type. If an
ItemDefinition has child components, it is those child/leaf components that are set as a built-in type.
For example Applicant Data and Monthly are compositions, whereas Age and Expenses are leaves set to a built-in type:
(c) Sparx Systems 2024 Page 94 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
· Type ': string', ': boolean' or ': number' after the name in the cell in the DMN Expression window
· Type 'string', 'boolean' or 'number' as the value of the tag 'Type' in the Properties window for the ItemDefinition
For composite ItemDefinitions, the context menu also offers options to create a child or a sibling component, or to delete
the selected item:
(c) Sparx Systems 2024 Page 95 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Allowed Value Enumerations are also used to support Auto Completion. When specifying values for an InputData
element or an input parameter that references an ItemDefinition in which Allowed Values have been defined, the user
can simply press the Spacebar and choose a value from the list.
You can also autocomplete by typing the first letter of the option you want to enter.
The input parameters and Output Clauses of Decision Tables also support the specification of allowable values. This
restricts the values that can be used when defining the rules in the table, but also allows the user to fast fill the rules by
pressing the Spacebar then selecting the required item.
A more complex ItemDefinition can include a number of Allowed Value Enumerations; for example:
(c) Sparx Systems 2024 Page 96 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Data Sets
Each InputData element typed by an ItemDefinition has a set of components, and multiple data sets can be defined to
provide different sets of values for those components. With this feature, a user performing a DMN Simulation can
quickly test the result of a decision by choosing different data sets. The data sets are associated with and based on the
ItemDefinition, but you can also work on them via the InputData element.
You add or update data sets using the 'Edit Data Set' dialog, which you invoke from the DMN Expression window for
either the ItemDefinition or the InputData element. Initially, the 'Edit Data Set' dialog shows a single set of components
with no values, under the set name 'default'. You can either leave this set with no values, or provide values; either way,
you can use this as a template to duplicate for new data sets. You cannot delete the 'default' data set.
When you access an InputData element in the DMN Expression window, the values in the 'default' data set are shown
against the components of the element. You can then click on the drop-down arrow in the toolbar and select any other
data set from the list. Note that if you leave the 'default' data set untouched, you can create a duplicate 'default' data set
and assign values to it, and that 'default' set will provide the values when you initially access the InputData element.
You can duplicate and delete any other data set that you create, export the data sets to a CSV file and import them from a
CSV file.
Note that if you create a data set and do not enter values, it is discarded when you close the dialog.
(c) Sparx Systems 2024 Page 97 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Access
Ribbon Simulate > Decision Analysis > DMN > DMN Expression > click on InputData
item : icon
Other
In a diagram, double-click on the DMN InputData element : icon.
(c) Sparx Systems 2024 Page 98 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Toolbar Options
Option Description
Click on this button to reload the data sets for the InputData.
(c) Sparx Systems 2024 Page 99 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
A Data Set is stored in a DMN InputData element and can be accessed using the icon on the DMN Expression
window.
This opens the InputData's 'Edit Data Set' dialog, which can contain multiple sets of values:
(c) Sparx Systems 2024 Page 100 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
(c) Sparx Systems 2024 Page 101 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
· Click on the icon on the DMN Simulation window; this opens the 'Select Element' dialog
· Select the BPMN DataObject element
· Click on the OK button
The Data Set is now viewable in the Notes of the DataObject.
2. Manual
To manually exchange this Dataset:
· Open the DMN Expression window for the InputData element
· Click on the Edit DataSet icon ; this opens the 'Edit Data Set' dialog
(c) Sparx Systems 2024 Page 102 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
(c) Sparx Systems 2024 Page 103 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Decision Service
Portions of this topic have been used verbatim or are freely adapted from the DMN Specification, which is available at:
[Link] This site contains a full description of the DMN and its capabilities.
A Decision Service exposes one or more decisions from a Decision model as a reusable element, which might be invoked
internally by another decision in the Decision model, or externally by a task in a BPMN process model.
When the Decision Service is called with the necessary input data and input decisions, it returns the outputs of the
exposed decisions.
This figure shows a Decision model that includes six decisions and three items of input data.
For DecisionService1, the:
· Output decision is {Decision1}
· Input decision is {Decision5}, and
· Input data is {InputData1}
As Decision1 requires Decision2, which is not provided to the service as input, the service must also encapsulate
(c) Sparx Systems 2024 Page 104 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
We can create a Decision Service element from the DMN pages of the Diagram Toolbox, and toggle [output] and
[encapsulated] partitions from the context menu.
You can only show an [encapsulated] partition when an [output] partition is shown.
Once the decisions and input data are put in the correct partition(s), you must run the 'Update DecisionService Interface"
command from the context menu to update the model.
(c) Sparx Systems 2024 Page 105 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Important: in order for the DMN simulation to work properly, please update the Decision Service interface whenever
you:
· Show/Hide the decision service partition(s)
· Add a decision to the decision service
· Remove a decision from the decision service
· Move a decision between partitions
· Add/Remove Decision Service Inputs: Input Data or Input Decisions
(c) Sparx Systems 2024 Page 106 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
To perform a model simulation on the Decision Service, work through these steps:
Step Description
1 Drag a Simulation Configuration Artifact element onto a diagram from the 'DMN
Components' page of the Toolbox, and double-click on it to open it in the DMN
Simulation window.
By default, all Decision Service elements and each single decision are listed for
selection in the drop-down field in the dialog toolbar.
2 Select a Decision Service element on which to run the simulation. In the example
we chose 'Routing Decision Service', so three input data items and five
encapsulated decisions (including one output decision) are loaded in the simulation
list.
Important: This list is drawn from the internal data of the Decision Service; make
sure you run the 'Update DecisionService Interface' command from the context
menu whenever the Decision Service model diagram is changed. Reload the
Decision Model by clicking the 'Refresh' icon (third from the left) on the DMN
Simulation window toolbar.
3 The input data and decisions are in the correct execution order. For example,
'Application risk score' will be executed before 'Post-bureau risk category', 'Post
bureau affordability' and 'Routing'. For each Input Data element, click on the
drop-down arrow in the 'Value' field and select the Data Sets to provide input data
values.
Validate the input data and decisions, and make any necessary corrections using the
(c) Sparx Systems 2024 Page 107 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
On the DMN Simulation window, click on the Save icon and on the button
on the toolbar.
4 The runtime execution result is shown both in the list and on the diagram. You can
also click on the 'Step-through' icon on the toolbar to debug the DMN model.
A good practice is to keep the DMN Expression window open while debugging.
The run time status of the expression (such as Decision Table, Boxed Context,
Literal Expression or Invocation) will show the details of the logic encapsulated by
the Decision or invoked Business Knowledge Model.
(c) Sparx Systems 2024 Page 108 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Access
Ribbon Simulate > Decision Analysis > DMN > Open DMN Simulation > Generate
Module
On the DMN Simulation window, select the DMN structure you want to generate the module from, in the data entry field
of the Toolbar.
Click on the 'Generate Module' tab, and then Ctrl+click on the names of the DMN elements you want to generate to the
server.
In the data entry field in the tab toolbar, select the language to generate in, and in the 'Module Path' field click on the
(c) Sparx Systems 2024 Page 109 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
icon and browse to the path location to generate the module into (note, for Java the path has to match the Package
structure).
When the generation is complete, click on the button to open the 'Test Module' tab for the generated module.
When you use the button to select the 'Test Module' tab, the 'DMN Module' field will be filled automatically with the
generated DMN Server path of the module you most recently generated on the 'Generate Module' tab. If necessary, on
the 'Decision' field click on the drop-down arrow and select the required Decision.
Click on the Add BPMN DataObject button ( ) in the Toolbar and select one or more (Ctrl+Click) BPMN2.0
DataObject(s) to add to the list in the main panel.
Now click the Run button on the toolbar. In the System Output window, this message indicates the DMN Server and
BPMN2.0 DataObject can work well with each other to evaluate the selected decision:
Running Test Client for DMN Server...
dmnServer.Application_risk_score: 133.0
Result : 133.0
The Running completed successfully.
If there are errors, create an Analyzer script by clicking the toolbar button and use the script to fix the issue.
Important: This 'Test Module' step is recommended before integrating [Link] with the Enterprise Architect
BPSim Execution Engine. See the Integrate a DMN Module Into BPSim for Simulation Help topic.
(c) Sparx Systems 2024 Page 110 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
· Variable Types: as DMN models use the FEEL language (Simulate with JavaScript), typing variables is not
compulsory; however, when generating code to languages that are compiled, you do have to type a variable - there
are context menu options and tag values for setting the type of a variable
· Since a DMN expression allows for spaces, in order to clarify the composite Input Data there must be a space before
and after the '.' in the expression; for example, 'Applicant data . Age' is valid, whereas 'Applicant [Link]' is not
valid
Note that when using the Auto Completion feature this issue will not arise
· Running validation will help you locate most of the modeling issues; do this before simulation and code generation
Notes
· Compiling with Java requires full read-write access to the target directory; compilation will fail if the module path is
set to just 'C:' or 'C:\Program Files (x86)'
(c) Sparx Systems 2024 Page 111 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
When you create a DMN model and simulate it in Enterprise Architect, the code driving the simulation is JavaScript; this
means that the variables do not need to be explicitly typed (the variable type is inferred from the value assigned to it).
However, for languages such as C++, C# and Java, the compiler will report an error that a variable does not have a type.
For generation to these languages you must run validation on the model and use the results to find variables that need
their type set. For example:
· Business Knowledge Model parameter - select the BKM element to view in the DMN Expression window, click on
the second button to open the 'Parameter' dialog, specify a type for the parameter
· Decision type - select the Decision element, open the Properties window, for the property 'variableType' select from
the 'Value' field
· Decision Table Input/Output clauses - on the Decision Table Input/Output clause, right-click to display the context
menu and choose the type
· Boxed Context variables - refer to the Boxed Context Help topic
(c) Sparx Systems 2024 Page 112 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
After using validation to fix any variable type issues, we can proceed to the 'Generate Module' page in the DMN
Simulation window.
· Select DecisionService1 in the top toolbar data entry field; all the elements involved in DecisionService1 will now
be included in the list
· Item Definition and Business Knowledge Model are global elements
· Input Data and Decisions are encapsulated in the DecisionService element
· The supported languages are C++, C#, Java and JavaScript; note that for JavaScript the generated .js file is the same
as the simulation script ('Simulate' tab | Run button drop down menu | Generate New Script (Scripting Window))
except that the simulation-related codes are omitted
· For Java, the 'Module Path' value must match the Package structure; in this example, the [Link] must be
generated to a directory to form a file path that ends with '\com\sparxsystems\dmn\[Link]' - you have to
manually create the directory structures for now
Click on the Generate Code button ( ) on the toolbar. This example will use Java; however, C++ and C# are the same.
These actions are performed:
· The .java file is generated to the path specified
· An Analyzer Script (Build script) for this Artifact is created
· The Build Script for this Analyzer Script is executed
· Progress messages are reported in the System Output window
If the model is valid, this process will return the message:
(c) Sparx Systems 2024 Page 113 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
If there are compiling errors, you can open the generated .java file by clicking the button next to the button on
the toolbar, manually fix the issue, and compile with the generated script until you are successful.
One common reason for a compile failure is that languages can have different grammars for an expression. You might
need to provide a value for a language to overwrite the default (right-click on a DMN Literal Expression | Edit
Expression).
Having generated the model to java code and successfully compiled it we now want to:
· Test this module's correctness
· Provide it with inputs
· Get the output Decision values
(c) Sparx Systems 2024 Page 114 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
The data carried by the selected data set will be generated to the BPMN DataObject's 'Notes' field.
· Click the button (2nd to the right on the toolbar of the 'Generate Module' tab) to open the 'Test Module' tab
· Click the on the toolbar to select the input BPMN DataObject elements
· Select the available outputs from the 'Decision' combo box, such as Get_Routing(), and click on the Run button on
the toolbar
(c) Sparx Systems 2024 Page 115 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
The execution result will be displayed in the Debug window. You can also open the test module file, set a breakpoint on
the line and debug in the DMN Module to do line-level-debugging.
We highly recommend you test your DMN Module with this window to guarantee that the DMN Module is functional
with the given inputs (from the BPMN DataObjects) and that it will successfully compute the result of the output.
Note: The DMN Module path is saved in the DMNSimConfiguration Artifact's 'Filepath' property.
Now, it is time to integrate the DMN module with the BPSim model.
The first step is to set up the usage dependency between the BPSim Artifact and the DMN Simulation Artifact.
Note: A BPSim Artifact can use multiple DMN modules if necessary. This is supported by simply putting all DMN
Artifacts on this diagram and drawing a Dependency connector from the BPSim Artifact to each DMN Simulation
Artifact.
These Help topics provide two examples of using these methods. See:
· Example: Integrate DMN Decision Service into BPSim Data Object and Property Parameter
· Example: Integrate DMN Business Knowledge Model into BPSim Property Parameter
(c) Sparx Systems 2024 Page 116 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
· When the simulation is running it will automatically load all DataObjects connecting to the task when the simulation
token passes through
· The second Business Rules task 'Decide bureau strategy' is configured to set the property 'Strategy' to the value
'DMNSimArtifact.Get_Strategy()'; you don't need to type this in - press Ctrl+Space to help you edit the expression
When these are set, click on the 'Execute' tab and simulate the model. You can then view the report or go to the 'Step'
page to do step debugging of the BPSim model.
(c) Sparx Systems 2024 Page 117 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
2. Connect the BKM to a Decision with a Knowledge Requirement connector. This Decision serves as a group name
for a number of BKM functions; you can simply input a number such as '10' to the expression. For example, if you
want to generate Java code with only five BKMs (considering your model might have over one hundred BKMs), you
can connect these five BKMs to a Decision and select this Decision in the DMN Simulation window, then all five
BKMs will be included automatically.
3. Generate Java code and (assuming everything is correct) the compile will be successful.
4. In the BPSim configuration, we simply use Intelli-sense to construct the expression for task 'Compute Delivery cost'.
In this example, the 'Generate furniture price and weight' task will generate random values to the properties 'Weight' and
'Price', then the 'Compute Delivery cost' task will pass the value to the Business Knowledge Model and the result will be
carried back to the property 'DeliveryCost'.
You can now execute the simulation, and step through the debug process to observe, for example, the attribute value
changes.
(c) Sparx Systems 2024 Page 118 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Suppose we have a Class Applicant with an operation AffordabilityForProduct that evaluates whether the applicant can
afford a loan product.
A simplified model resembles this:
The Class Applicant contains two attributes, which are actually calculated from more basic data such as the applicant's
monthly income, expenses, existing repayments, age and employment status.
In this example, however, we simplify the model by skipping these steps and providing disposable income and risk score
directly.
DMN Models
In this example, we have two disjoint DMN Models to show that a UML Class can integrate multiple DMN Models.
Installment Calculator
This DMN model computes the monthly repayment based on amount, rate and terms. It is composed of an InputData, a
Decision and a Business Knowledge Model.
(c) Sparx Systems 2024 Page 119 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Note: In this example, we focus on how to integrate DMN modules into a Class element; the DMN elements' detail is not
described here.
Generate code for both DMN Models
Click on the Generate Code icon, and check that you can see this string in the System Output window, 'DMN' tab:
DMN Module is successfully compiled.
(c) Sparx Systems 2024 Page 120 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Note: Since this model uses a built-in function PMT, the DMN Library has to be included:
Click on the Generate Code icon, and check that you can see this string in the System Output window, 'DMN' page:
DMN Module is successfully compiled.
(c) Sparx Systems 2024 Page 121 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Use the Quick Linker to create a Dependency connector from the Class Applicant to each of the DMN Artifacts.
On creation of the connector, a dialog will prompt you to choose the operation to be bound to the DMN module.
After DMN Bindings, Intelli-sense for the operation's code editor will support DMN Modules. To trigger the
Intelli-sense, use these key combinations:
· Ctrl+Space - in most of the cases
· Ctrl+Shift+Space - when Ctrl+Space does not work after a parenthesis '('; for example, a function's arguments, or
inside an 'If' condition's parentheses
(c) Sparx Systems 2024 Page 122 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
This illustration shows that we are selecting 'Get_Required_monthly_installment()' from the Installment_Calculator.
This is the final implementation for the operation.
(c) Sparx Systems 2024 Page 123 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
(c) Sparx Systems 2024 Page 124 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
Access
In the Browser window, select the Package into which to import the XML file. Then use one of the methods outlined
here to open the 'Import Package from DMN 1.1 XML' dialog.
Ribbon Publish > Model Exchange > Import > DMN 1.1
1
In the 'Filename' field, type in the source file path and name, or click on the
icon to locate and select the file.
2 Click on the Import button to import the file into the Package.
1. Download the zip file at this link and extract it to your file manager.
2. Browse for the folder examples/Chapter 11/.
3. Click on the file Chapter 11 [Link] and import it as a DMN 1.1 format file.
These diagrams are imported to show different perspectives of the model:
· DRD of all automated decision-making
· DRD for the Review Application decision point
· DRD for the Decide Routing decision point
· DRD for the Decide Bureau Strategy decision point
These diagrams are imported to define the Decision Services:
· Bureau Strategy Decision Service
· Routing Decision Service
The 'Bureau Strategy Decision Service' diagram is shown here. It has two Input Data elements (Applicant data,
Requested product), two Output Decisions (Bureau call type, Strategy) and five Encapsulated Decisions. Note that the
invoked Business Knowledge Models are not shown on the diagram.
(c) Sparx Systems 2024 Page 125 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
In order to generate production code from the model, you might have to run a validation and simulation to ensure that the
imported model has the correct expressions.
1. Create a DMN Sim Configuration Artifact on any of the listed diagrams, and double-click on it to open it in the
DMN Simulation window.
2. The Decision Services and Decisions are listed in the target drop-down field. Once you specify a target, all the
required elements are listed in the window.
3. Click on the Validate button (4th on the toolbar). If any error or warning messages display, we suggest that you to
fix the problems as directed by the error or warning descriptions, before performing the simulation.
4. Provide appropriate values for the inputs, and either run the simulation or step-debug the model.
Note: The 'Bureau Strategy Decision Service' example is also available in the EAExample Model. From the 'Getting
Started' diagram, select 'Business Modelling > DMN Examples > Bureau Strategy Decision Service'.
(c) Sparx Systems 2024 Page 126 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
More Information
In Enterprise Architect, the Decision Model and Notation (DMN) feature serves a crucial purpose: providing the
essential constructs for modeling decisions effectively. This functionality allows organizational decision-making to be
visually depicted in diagrams within the tool, enabling business analysts to accurately define decision models. Enterprise
Architect supports the optional automation of these decision models, streamlining decision-making processes.
Enterprise Architect's DMN capabilities facilitate seamless sharing and interchange of Decision Models between
organizations. This interoperability ensures that decision models can be easily communicated and collaborated upon,
fostering efficient decision-making across different teams and stakeholders.
(c) Sparx Systems 2024 Page 127 of 128 Created with Enterprise Architect
Decision Model and Notation (DMN) 16 October, 2024
(c) Sparx Systems 2024 Page 128 of 128 Created with Enterprise Architect