Please note : This help page is not for the latest version of Enterprise Architect. The latest help can be found here.
Prev | Next |
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. When the expression is getting complicated, you might prefer a Boxed Context, or in order to improve the readability you can encapsulate some logic as a function in the DMN Library. See the example at the end of this page.
Access
Ribbon |
Simulate > Decision Analysis > DMN > DMN Expression : select or create a Decision or BusinessKnowledgeModel |
Other |
Double-click on a DMN Decision or BusinessKnowledgeModel |
Toolbar Options
Options |
Description |
See also |
---|---|---|
Click on this button to save the configuration to the current Decision or BusinessKnowledgeModel. |
||
Click on this button to edit parameters for the Business Knowledge Model. |
||
This option is disabled for Literal Expressions. |
||
This option is disabled for Literal Expressions. |
||
This option is disabled for Literal Expressions. |
||
This option is disabled for Literal Expressions. |
||
Click on this button to validate the Literal Expression. Enterprise Architect will perform a series of validations to help you locate errors in the Expression. |
DMN Expression Validation | |
This button is enabled when the literal expression is defined for a BusinessKnowledgeModel. |
BusinessKnowledgeModel & Test Harness |
Example — Payment of 2 Decimals
This Business Knowledge Model (BKM) Payment_2_decimal is implemented as a Literal Expression.
- The BKM defines three parameters: Rate, Term and Principle
Give values for the Test Harness and evaluate the model:
- 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 implementation is 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:
Expression Editor and Intelli-sense Support
In accordance with the FEEL language specification, the parameter names can contain spaces. This feature makes the expression easier to read. Enterprise Architect also provides Intelli-sense support for editing the expressions with minimal typing and fewer mistakes.
Given a decision hierarchy such as this, the expression in 'Decision3' should be able to use the required decisions (variables).
Right-click on the Expression and select the menu option 'Edit Expressions...' to display the 'Expression' dialog.
Press
to show the Intelli-sense menu:- For 'BKM', all the parameters will be included
- For 'Decision', all the required Decisions will be included
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.