Prev Next

Literal Expression

A Literal Expression is the simplest form of DMN expression. It is commonly used as one-liner or if-else block. When the expression is getting complicated, a Boxed Context is a better choice or encapsulate some logic as a function in DMN Library in order to improve readability. You will see an example at the end of this page.

Access

Ribbon

Simulate > Decision Analysis > DMN > DMN Expression, then select / create a Decision or BusinessKnowledgeModel

Other

Double-click on an 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 Expression.

This option is disabled for Literal Expression.

This option is disabled for Literal Expression.

This option is disabled for Literal Expression.

Click on this button to validate the Literal Expression. EA will perform a series of validations to help the modeler to pickup 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 Literal Expression.

  • The BKM defines 3 parameters: Rate, Term, Principle

Give values for the Test Harness and Evaluate the model:

  • The runtime parameter value will be displayed. E.g. Rate = 00.005
  • The BKM's result will be evaluated by the literal expression and the value is displayed on the declaration line. E.g. return = 1798.65

Although the implementation is one liner, it is quite complicated. We can re-factor this model with Built-In function and Boxed Context to improve readability:

  • The Boxed Context defines 2 variable-expression pairs entries, these variables serves 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 which is 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 Literal Expression:

Expression Editor and IntelliSense Support

The parameter names may contain space according to FEEL language specification. This feature makes the expression easy to read. In order to help the user to edit the expressions with fewer typing and make less mistake, EA provided IntelliSense support for editing expressions:

Given a decision hierarchy like this, the expression in Decision3 should be able to use the required decisions(variables ).

Context menu on the Expression | Click the menu item "Edit Expressions..." to bring up the Expression Dialog.

Press "Ctrl + Space" to show the IntelliSense menu:

  • For BKM, all the parameters will be included.
  • For Decision, all the required Decisions will be included.

The DMN Model may be generated as source code for language JavaScript/Java/C#/C++, since some languages may have different syntax for some expressions, EA provided language override pages for each language. If no override code is specified for a language, the expression defined for FEEL language will be used.

In the generated code, the space inside a variable name will be replaced by an underscore.

Learn more