jBPM DMN Tutorial – Using Functions in DMN (FEEL Functions Explained)
🚀 Introduction
In jBPM, DMN (Decision Model and Notation) is widely used to model business rules, decision logic, and calculations.
One of the most powerful parts of DMN is the ability to use functions written in:
-
FEEL (Friendly Enough Expression Language)
-
Java (via invocation)
-
External logic (via WorkItemHandlers + DMN inputs)
In this blog, we will focus on the DMN FEEL functions, the most commonly used and the most powerful inside DMN models.
🧩 What is a DMN Function?
A function in DMN is a reusable block of logic that can:
✔ Take inputs
✔ Perform calculations
✔ Return an output
You can call functions inside decision tables, literal expressions, or context entries.
DMN in jBPM supports:
-
Built-in FEEL functions
-
Custom FEEL functions
-
Boxed functions (literal function expressions)
🔵 1. Built-in FEEL Functions
FEEL provides many ready-made functions.
👉 Commonly used DMN FEEL functions:
| Function | Purpose |
|---|---|
string(length) | Convert values to string |
number() | Convert text to number |
lower() / upper() | Convert case |
contains(text, substring) | Check if substring exists |
substring(text, start, length) | Extract text |
sum(list) | Add values in list |
min(list) / max(list) | Min & max values |
today() / now() | Date & time |
duration() | Time difference |
🟢 Example: Using Built-in Functions in a Decision Table
🧾 Use Case
Calculate the final price based on discount logic.
📌 Inputs
-
amount -
discountPercent
📌 Literal Expression using FEEL Function
📌 Example in Decision Table
| Condition (amount) | Condition (discountPercent) | Output Expression |
|---|---|---|
| > 1000 | 10 | amount - (amount * 0.10) |
| <= 1000 | 5 | amount - (amount * 0.05) |
🟡 2. Custom FEEL Functions
You can define your own functions inside the DMN model.
There are two ways:
🟡 A. Boxed Function (Literal Function)
Example:
Define a function to calculate age based on birth year.
You can then call it:
Returns:
🟡 B. Named Function (Reusable)
Inside your DMN context, you can define reusable functions.
Example:
You can then use:
🔴 3. Java Functions Inside DMN (Advanced)
jBPM allows invoking Java classes from DMN using:
-
KIE WorkItemHandlers
-
Java functions exposed to DMN context
-
Custom KieRuntime Extensions
Example Java Method:
You can expose it via:
And call inside DMN:
📘 Full Example: Discount Calculation Using DMN Function
DMN Function:
Decision Table Calling the Function:
| Amount | Discount | Result |
|---|---|---|
| >1000 | 10 | calculate(amount, discount) |
| <=1000 | 5 | calculate(amount, discount) |
FEEL Expression:
🔗 Linking DMN Function with jBPM Workflow
BPMN Workflow:
Business Rule Task Configuration:
-
DMN File:
discount.dmn -
Model name:
DiscountModel -
Decision:
FinalPrice
Runtime call from Java:
Output variables will include:
📊 Summary Table
| Feature | Supported in jBPM DMN? | Notes |
|---|---|---|
| Built-in FEEL functions | ✅ | Very commonly used |
| Custom FEEL functions | ✅ | Best for business rules |
| Boxed functions | ✅ | DMN-standard |
| Java functions | ⚠️ | Advanced integration |
| Script functions | ❌ | Not part of DMN standard |
👉 Watch “DMN” in Action:
A live demo showing all components of DMN:
🎬 YouTube: Learn IT with Shikha video 1
🎬 YouTube: Learn IT with Shikha video 2
👉 Source code: LearnITWithShikha/DMNExamples
🎯 Conclusion
DMN functions in jBPM allow you to:
✔ Reduce complexity
✔ Reuse logic
✔ Make business rules clean and maintainable
✔ Share logic across multiple decision tables
✔ Implement FEEL and Java-based functions
DMN + FEEL functions = powerful, clean, and highly reusable decision logic.
If your decision logic repeats across your rules, ALWAYS convert it into a DMN function.
💼 Professional Support Available
If you are facing issues in real projects related to enterprise backend development or workflow automation, I provide paid consulting, production debugging, project support, and focused trainings.
Technologies covered include Java, Spring Boot, PL/SQL, Azure, and workflow automation (jBPM, Camunda BPM, RHPAM).
🌐 Website: IT Trainings | Digital metal podium
Comments
Post a Comment