Function Definition
A Function Definition allows you to define reusable logic within DMN.
Types of Functions
-
FEEL Function:
- Logic is defined using a pure FEEL expression.
- Example:
function(a, b) a + b
-
External Function:
- Links to logic executed outside the DMN XML.
Syntax
function(parameter1, parameter2)
body_expression
FAQ
Where do Function Definitions live in a DMN model?
Most commonly inside a Business Knowledge Model (BKM) — the BKM is the named, reusable wrapper and its body is a Function Definition. Decisions and other BKMs then invoke the BKM by name through a boxed Invocation (or directly in FEEL syntax from a Literal Expression). A Function Definition can also appear as the value of any other boxed expression — for example, as a Context entry value — but the BKM pattern is the standard way to make functions discoverable and reusable across the model.
Can a Function Definition be recursive?
A FEEL function body can reference the enclosing BKM by name and call itself, which gives you a recursive function — but FEEL is a side-effect-free expression language with no general looping construct other than for/every/some, so deep recursion is rarely the right tool. For iterative computation, prefer for loops over a list or use FEEL's collection built-ins (sum, count, every, filter expressions). Reach for recursion only when the problem is genuinely recursive (tree traversal, nested data) and the depth is bounded.
What's the FEEL syntax for defining a function inline?
function(param1, param2) body-expression — the body is a single FEEL expression that references the parameters by name. Example: function(a, b) a + b is a two-argument addition. Inline function definitions are useful as arguments to higher-order built-ins or for short helpers, but the standard way to make a function reusable is to wrap it in a BKM so it has a name and shows up in the model's dependency graph.