DMN FEEL Handbook
This handbook serves as a comprehensive reference for the FEEL expression language from the DMN specification, as implemented within the Aletyx Enterprise Build of Kogito and Drools. The credit for this FEEL Handbook originates in the KIE Group™ Community found here and this guide was seen as an extension and further enhancement to it since the KIE Group has been transferred to Apache KIE and this is not yet a part of the Apache repositories.What is DMN FEEL?
FEEL (Friendly Enough Expression Language) is the expression language defined in the Decision Model and Notation (DMN) standard. It provides business analysts, developers, and domain experts with a common language for expressing decision logic in a business-friendly way. FEEL was designed with these key principles:- Business-friendly syntax: Easy to read and write for non-programmers
- Side-effect free: Expressions cannot modify external state
- Simple data model: Works with common business data types (numbers, dates, strings, etc.)
- Three-valued logic: Supports
true,false, andnullvalues for handling unknown/undefined states
Why Learn FEEL?
While there are many expression languages available, FEEL offers unique advantages for business decision modeling:- Bridge between business and IT: Common language that both business analysts and developers can understand
- Standardized: Part of the OMG DMN specification, ensuring consistency across implementations
- Designed for decisions: Optimized specifically for decision logic with appropriate built-in functions
- Readable expressions: Logic expressed in a way that business stakeholders can validate
- Integration with DMN: Seamless use within decision tables, decision requirements diagrams, and other DMN elements
Quick Start Guide: Essential FEEL Concepts
If you’re new to FEEL or need a refresher, here are the key concepts to understand:Basic Data Types and Literals
Simple Expressions
Decision Table Logic in FEEL
The power of FEEL becomes apparent in decision tables. For example, a loan approval decision table might use FEEL expressions like:- Input expression:
applicant.creditScore - Input expression:
applicant.debtToIncome - Output expression:
if applicant.creditScore >= 700 and applicant.debtToIncome < 0.3 then "Approved" else "Declined"
Common Business Use Cases for FEEL
Getting Started with FEEL in Your Organization
- Start small: Begin with simple decision tables using basic FEEL expressions
- Practice with real examples: Convert existing business rules to FEEL expressions
- Use validation tools: Leverage DMN-compliant tools to check your FEEL syntax
- Build a library: Create a repository of common FEEL patterns for your organization
- Integrate with systems: Connect your DMN models to your business applications
Introduction to FEEL Data Types
FEEL supports a rich set of data types designed to handle common business decision needs. Understanding these types helps you model your business domain accurately.Number
BigDecimals with MathContext DECIMAL128.
String
Boolean
null (unknown/undefined) alongside true and false. This is particularly useful in business scenarios where information might be missing or not applicable.
Date
Time
Date and Time
Duration (Days and Time, Years and Months)
- Days and Time Duration - For precise intervals in days, hours, minutes, and seconds
- Years and Months Duration - For calendar-based periods like contract terms
Range (Interval)
[ and ] indicate inclusive endpoints (closed intervals), while parentheses ( and ) indicate exclusive endpoints (open intervals). This precision is essential in business rules where boundary conditions matter.
List
Context
context(), context put(), context merge()) that make it easier to create and manipulate these structures. This is particularly valuable for progressive enrichment of customer profiles, order details, or application evaluations.
Function
If Expression: Conditional Business Logic
if <condition> then <result1> else <result2>.
Important: The else part is always mandatory in FEEL expressions, unlike some programming languages. This forces explicit handling of all cases, which is a good practice for business rules where all scenarios should be accounted for.
For Expression: Iterative Processing
- Processing order line items
- Calculating revenue by product category
- Identifying customers matching specific criteria
- Transforming raw data into business-friendly formats
Quantified Expressions: Verification Logic
Some: At Least One Match
some expression checks if at least one element in a list or range satisfies a condition. This is particularly useful for flagging scenarios where a single match is significant.
Business Applications:
- Fraud detection (any suspicious transaction)
- Compliance verification (any missing document)
- Risk assessment (any critical risk factor present)
- Eligibility checking (any qualifying condition)
Every: All Must Match
every expression checks if all elements in a list or range satisfy a condition. This is essential for rules requiring universal compliance or complete verification.
Business Applications:
- Compliance verification (all requirements met)
- Order fulfillment (all items available)
- Application completeness (all fields provided)
- Quality control (all tests passed)
In Expression: Range Checking
in expression checks if a value falls within a specified range. This is a powerful tool for expressing business rules involving thresholds, limits, and acceptable values.
Business Applications:
- Credit score evaluation
- Age verification
- Pricing tiers
- Performance metrics
- Inventory management
- Service level agreement monitoring
Boolean Logic in Business Rules
and and or operators, allowing for the modeling of complex business conditions. The three-valued approach handles unknown (null) values in addition to true and false.
Truth Tables for Three-Valued Logic:
AND Operator:
OR Operator:
!!! note “
and and or precendence is important!
String Operations
- Data formatting for display
- Validation of format-specific inputs
- Extraction of components from complex strings
- Pattern matching in text data
Arithmetic Operations
- Financial calculations
- Pricing models
- Resource allocation
- Performance metrics
- Forecasting
Extracting and Manipulating String Data
String Testing and Validation
String Transformation
Comprehensive String Function Reference
substring(string, start position, length?)
string: The source stringstart position: Position to start from (1 = first character, negative numbers count from end)length(Optional): Number of characters to include
string length(string)
string: The string to measure
upper case(string) and lower case(string)
string: The string to transform
substring before(string, match) and substring after(string, match)
string: The source stringmatch: The string to search for
replace(input, pattern, replacement, flags?)
input: Source stringpattern: Search pattern (can be regex)replacement: Replacement textflags(Optional): Regex flags like “i” for case-insensitive
matches(input, pattern, flags?)
input: String to testpattern: Regular expression patternflags(Optional): Regex flags
split(string, delimiter)
string: The string to splitdelimiter: Regular expression pattern for splitting
string join(list, delimiter)
list: List of strings to joindelimiter: String to insert between elements (optional)
Business Scenario Examples
Customer Data Formatting
Product Code Processing
Document and Reference Number Processing
Quick Start Guide: The FEEL Essentials
If you’re new to FEEL or just need a refresher, here are the most essential concepts and functions to know. This section will help you get productive quickly with the most commonly used aspects of FEEL.What Makes FEEL Different?
FEEL (Friendly Enough Expression Language) is designed as a common ground between business analysts, programmers, domain experts, and stakeholders. Its primary goal is to make decision logic approachable for all users while remaining powerful enough for complex business requirements. Key Characteristics:- Side-effect free - Expressions cannot modify external state
- Simple data model - Works with numbers, dates, strings, lists, and contexts
- Business-friendly syntax - Designed for a broad audience beyond just programmers
- Three-valued logic - Supports
true,false, andnullvalues
Essential FEEL Expressions
Most Commonly Used FEEL Functions
FEEL Data Types in Business Context
FEEL supports a rich set of data types designed to handle common business decision needs. Understanding these types helps you model your business domain accurately.Number
FEEL Number ExamplesBigDecimals with MathContext DECIMAL128.
String
FEEL String ExamplesBusiness ConsiderationRemember that string values need explicit comparison operations.
"123" is different from the number 123, which matters when validating input from systems that may provide numeric identifiers as strings.Boolean
FEEL Boolean Examplesnull (unknown/undefined) alongside true and false. This is particularly useful in business scenarios where information might be missing or not applicable.
Date
FEEL Date Example with Business ContextTime
FEEL Time Examples in Business ContextDate and Time
Date and Time FEEL Examples in Business ContextDuration (Days and Time, Years and Months)
Duration FEEL Examples in Business Context- Days and Time Duration - For precise intervals in days, hours, minutes, and seconds
- Years and Months Duration - For calendar-based periods like contract terms
Range (Interval)
FEEL Range/Interval Examples in Business Context[ and ] indicate inclusive endpoints (closed intervals), while parentheses ( and ) indicate exclusive endpoints (open intervals). This precision is essential in business rules where boundary conditions matter.
List
FEEL List Examples in Business ContextBusiness ConsiderationIn FEEL, list indexing starts at 1, not 0 as in many programming languages. This can be confusing for developers but is more natural for business users.
Context
FEEL Context Examples in Business Contextcontext(), context put(), context merge()) that make it easier to create and manipulate these structures. This is particularly valuable for progressive enrichment of customer profiles, order details, or application evaluations.
Core FEEL Expressions for Business Logic
FEEL provides several expression types that form the building blocks of decision logic. Understanding these expressions is essential for creating effective business rules.If Expression: Conditional Business Logic
If Expression in Business Contextif <condition> then <result1> else <result2>.
For Expression: Iterative Processing
For Expression in Business Context- Processing order line items
- Calculating revenue by product category
- Identifying customers matching specific criteria
- Transforming raw data into business-friendly formats
Quantified Expressions: Verification Logic
Some: At Least One Match
Using “Some” in Business Rulessome expression checks if at least one element in a list or range satisfies a condition. This is particularly useful for flagging scenarios where a single match is significant.
Business Applications:
- Fraud detection (any suspicious transaction)
- Compliance verification (any missing document)
- Risk assessment (any critical risk factor present)
- Eligibility checking (any qualifying condition)
Every: All Must Match
Using “Every” in Business Rulesevery expression checks if all elements in a list or range satisfy a condition. This is essential for rules requiring universal compliance or complete verification.
Business Applications:
- Compliance verification (all requirements met)
- Order fulfillment (all items available)
- Application completeness (all fields provided)
- Quality control (all tests passed)
In Expression: Range Checking
Range Checking in Business Rulesin expression checks if a value falls within a specified range. This is a powerful tool for expressing business rules involving thresholds, limits, and acceptable values.
Business Applications:
- Credit score evaluation
- Age verification
- Pricing tiers
- Performance metrics
- Inventory management
- Service level agreement monitoring
Boolean Logic in Business Rules
Boolean Logic in Business Contextand and or operators, allowing for the modeling of complex business conditions. The three-valued approach handles unknown (null) values in addition to true and false.
Truth Tables for Three-Valued Logic:
AND Operator:
OR Operator:
Precedence Rule
and has higher precedence than or. Use parentheses when combining operations to ensure the intended evaluation order.String Functions for Business Data Processing
String processing is essential for business rules involving product codes, customer information, addresses, and other text data. FEEL provides a comprehensive set of string functions to help with these common tasks.Extracting and Manipulating String Data
String Extraction Functions in Business ContextString Testing and Validation
String Validation in Business RulesString Transformation
String Transformation for Business DataList Functions for Collection Processing
Business decisions often involve processing collections of items, such as order lines, customer segments, or transaction histories. FEEL provides powerful functions to analyze and manipulate these collections.Basic List Operations
Essential List Functions in Business ContextList Modification and Creation
List Manipulation in Business ScenariosList Analysis and Filtering
Advanced List Analysis for Business IntelligenceStatistical Functions for Business Analytics
Statistical Analysis for Business MetricsContext Functions for Complex Data Structures
Added in DMN 1.4, context functions provide powerful capabilities for working with structured business data like customer profiles, product configurations, and application states.Context Creation and Modification
Building and Updating Contexts for Business DataContext Inspection and Extraction
Analyzing Context Data for Business ProcessingRange Functions for Temporal and Sequential Business Logic
Range functions offer sophisticated ways to express relationships between time periods, numerical ranges, and sequences. These are particularly valuable for business rules involving schedules, eligibility periods, and process sequences.Temporal Relationship Analysis
Analyzing Time Relationships in Business ProcessesFEEL Data Types Reference Material
FEEL supports the following data types:FEEL Values in Detail
Number
FEEL Number ExamplesBigDecimals with MathContext DECIMAL128. FEEL supports only one number data type, used for both integers and floating point numbers, there isn’t a distinction between these and the numerical accuracy seen in different types of Java integers/numbers/decimals/etc should be treated as a BigDecimal function.
FEEL numbers use a dot (.) as a decimal separator and don’t support -INF, +INF, or NaN. Invalid numbers are represented as null.
The Aletyx Enterprise Build of Drools extends the DMN specification with additional number notations:
- Scientific notation:
1.2e3(equivalent to1.2*10**3) - Hexadecimal:
0xff(equivalent to decimal255) - Type suffixes:
f,F,d,D,l,L(ignored but allowed for compatibility)
String
FEEL String Examples"123" is different than 123 - so if you need to parse out parts of the string, functions will need to be used to do so.
Boolean
FEEL Boolean Examplestrue, false, or null.
Date
FEEL Date ExampleDate Properties
Date literals aren’t directly supported in FEEL, but you can construct date values using the built-indate() function. Date strings follow the format defined in XML Schema: "YYYY-MM-DD".
Date values have these accessible properties:
Accessing Date Properties in FEEL
Time
FEEL Time ExamplesAccessing Properties of Time
Time literals aren’t directly supported, but you can construct time values using thetime() function. Time strings follow XML Schema format: "hh:mm:ss[.uuu][(+-)hh:mm]".
Time values have these accessible properties:
Accessing Time Properties with FEEL
Date and Time
Date and Time FEEL ExamplesAccessing Date and Time Properties
Date and time values combine both date and time information. They can be created using thedate and time() function with the format "<date>T<time>".
Date and time values have these accessible properties:
Properties
Days and Time Duration
Days and Time Duration FEEL ExamplesAccessing Day and Time Duration Properties in FEEL
Days and time duration values represent periods of time in days, hours, minutes, and seconds. They can be created using theduration() function with strings that follow the XML Schema duration format.
Days and time duration values have these accessible properties:
Accessing Duration Properties in FEEL
Years and Months Duration
Years and Months Duration FEEL ExamplesAccessing Year and Months Duration Properties
Years and months duration values represent periods of time in years and months. They can be created using theduration() function with strings that follow the XML Schema duration format, but only with year and month components.
Years and months duration values have these accessible properties:
Access Duration Years and Months Properties
Function
FEEL Function Examplea and b and returns the result.
Context
FEEL Context ExampleUnderstanding FEEL Context Literals
FEEL has context literals that you can use to create contexts. A context in FEEL is a list of key and value pairs, similar to maps in languages like Java. In the example, the expression creates a context with two entries, x and y, representing a coordinate in a chart. In DMN 1.2, another way to create contexts is to create an item definition that contains the list of keys as attributes, and then declare the variable as having that item definition type.Java Implementation in Drools DMN API
The Drools DMN API supports DMNItemDefinition structural types in a DMNContext in two ways:
- User-defined Java type: Must be a valid JavaBeans object defining properties and getters for each of the components in the DMN ItemDefinition. If necessary, you can also use the @FEELProperty annotation for those getters representing a component name which would result in an invalid Java identifier.
- java.util.Map interface: The map needs to define the appropriate entries, with the keys corresponding to the component name in the DMN ItemDefinition.
New Context Functions since DMN 1.2
Several new context functions were added in DMN 1.4, with the most useful beingcontext put(). Before this function, adding a column to a table required iterating a context BKM with one context entry per column creating more complex implementations than should’ve been required.
DMN 1.4 introduced three new built-in functions for contexts: context(), context put(), and context merge().
These functions make it easier to create and manipulate contexts:
- context() - Takes a list of key-value pairs and creates a context with those entries
- context put() - Adds or updates a key-value pair in an existing context
- context merge() - Combines multiple contexts into a single context
Range (Interval)
FEEL Range Interval ExamplesExamples of Range
FEEL Properties of Range
Ranges represent intervals of values. The brackets[ and ] indicate inclusive endpoints (closed intervals), while parentheses ( and ) indicate exclusive endpoints (open intervals).
Range values have these accessible properties:
Accessing Properties of Ranges in FEEL
List
FEEL List ExampleList Indexing
Lists contain ordered collections of items. In FEEL, you can create lists using square brackets with comma-separated values. Elements in a list can be accessed by index, with the first element at index 1: FEEL List IndexingList Negative Indexing
Negative indexes access elements from the end of the list: FEEL List Negative IndexingFEEL Expressions
FEEL provides several expression types that form the building blocks of decision logic.If Expression
Examples Utilizing If Expression in FEELelse part is always mandatory in FEEL.
For Expression
Utilizing the For Expression in Feel ExamplesQuantified Expressions
Some
Utilizing the Some Expression in FEEL Examplessome expression checks if at least one element in a list or range satisfies a condition. This allows for determining if at least item in the expression list meets the conditions.
Every
Utilizing the Every Expression in FEEL Examplesevery expression checks if all elements in a list or range satisfy a condition. Every element must match to be evaluated as true.
In Expression
Utilization of the In Expression Examplesin expression checks if a value falls within a specified range. With the in expression, it is very important if ranges are used to be aware of the use of inclusive [] or exclusive ().
Boolean Logic
Using Boolean Logic in FEEL Examplesand and or operators. Note that and has higher precedence than or.
String Concatenation
String Concatenation FEEL Examples+ operator. This allows building larger strings or merging statements together.
String Functions
This section covers the built-in functions for working with strings in FEEL.substring(string, start position, length?)
Substring FEEL Examples1.
NoteIn FEEL, Unicode characters are counted based on their code points.
string length(string)
String Length FEEL Examplesupper case(string)
Transforming Strings to Upper Case in FEEL Examplelower case(string)
Transforming Strings to Lower Case in FEEL Examplesubstring before(string, match)
Using Substring Before in FEEL Examplessubstring after(string, match)
Using Substring After in FEEL Examplesreplace(input, pattern, replacement, flags?)
Using the Replace Function in FEEL ExamplesNoteThis function uses regular expression parameters as defined in XQuery 1.0 and XPath 2.0 Functions and Operators.
contains(string, match)
Using the Contains Expression in FEEL Exampletrue if the string contains the match.
starts with(string, match)
Using the Starts With Function in FEEL Exampletrue if the string starts with the match.
ends with(string, match)
Exampletrue if the string ends with the match.
matches(input, pattern, flags?)
Using the Matches Fucntion in FEEL Exampletrue if the input matches the regular expression.
NoteThis function uses regular expression parameters as defined in XQuery 1.0 and XPath 2.0 Functions and Operators.
split(string, delimiter)
Using the Split Function in FEEL ExamplesNoteThis function uses regular expression parameters as defined in XQuery 1.0 and XPath 2.0 Functions and Operators.
string join(list, delimiter)
Using the String Join in List FEEL Function Examplesdelimiter can be an empty string.
Null elements in the list parameter are ignored.
If list is empty, the result is the empty string.
If delimiter is null, the string elements are joined without a separator.
string join(list)
String Join Function in FEEL Examplelist parameter are ignored.
If list is empty, the result is the empty string.
List Functions
This section covers the built-in functions for working with lists in FEEL.NoteIn FEEL, the index of the first element in a list is
1. The index of the last element in a list can be identified as -1.list contains(list, element)
FEEL List Contains Function in FEEL Exampletrue if the list contains the element.