DMN Functions in jBPM
💡 Introduction
In jBPM, we often use DMN Decision Tables to define rules visually.
But sometimes, the same logic (for calculations, validations, or text manipulation) is needed across multiple rules.
Instead of repeating that logic, you can define it once as a 📦 Function inside DMN and reuse it in your Decision Tables, Literal Expressions, or Contexts.
This makes your decision models more modular, maintainable, and business-friendly.
🧠 1️⃣ What Is a Function in DMN?
In DMN, a function is a reusable piece of logic written in FEEL (Friendly Enough Expression Language).
It can accept input parameters and return values just like a normal programming function.
✅ Example of a simple FEEL function:
📊 You can define it:
-
Inside a Context
-
As a separate Decision node
-
Or as a Business Knowledge Model (BKM) for global reuse
⚙️ 2️⃣ Why Use Functions in DMN
| Reason | Benefit |
|---|---|
| 🧾 Reusability | Define once, use across multiple decisions |
| ⚙️ Maintainability | Update logic in one place only |
| 🔍 Clarity | Keeps decision tables cleaner |
| 🚀 Performance | FEEL functions are lightweight and fast |
🧩 3️⃣ Example Scenario
Let’s say we want to evaluate employee bonuses based on salary and performance rating.
We’ll create:
-
A function to calculate the base bonus
-
A decision table to decide the final bonus category
🧱 4️⃣ Step-by-Step: Create Function in DMN
🧮 Step 1: Define Function Node
In Business Central → Design → Create → DMN,
add a Business Knowledge Model (BKM) or Decision Node named CalculateBonus.
Inside its boxed expression, define:
This function takes two inputs (salary and rating) and returns the computed bonus.
🧩 5️⃣ Step 2: Create Decision Table That Uses the Function
Now, create another Decision node named BonusDecision.
Input Data:
-
salary -
rating
Decision Table Configuration:
| Rating | Bonus | Description |
|---|---|---|
"A" | CalculateBonus(salary, rating) | "Excellent" |
"B" | CalculateBonus(salary, rating) | "Good" |
"C" | CalculateBonus(salary, rating) | "Average" |
✅ FEEL Expression Example:
🎯 This directly calls the previously defined function node!
🧩 6️⃣ Step 3: DMN Context Example (Alternate Way)
If you prefer defining functions inline within a context:
✅ In this example, the FinalResult uses the CalculateBonus function directly.
💻 7️⃣ Step 4: Call DMN from jBPM or Java
You can now invoke the DMN model in your process flow or Java code.
Java Example:
✅ Output Example:
🧠 8️⃣ Using Functions Across Multiple Decisions
Once defined, your function (like CalculateBonus) can be reused in:
-
Decision Tables
-
Literal Expressions
-
Other Functions
-
FEEL conditions
For example:
🧰 9️⃣ Troubleshooting Tips
| Issue | Cause | Solution |
|---|---|---|
❌ Function not found | Function not linked or imported | Ensure decision or BKM is connected to the dependent node |
| ⚠️ Null value | Input variables not mapped | Verify salary and rating are correctly passed |
| 🧮 Wrong calculation | FEEL syntax issue | Use Preview DMN XML to confirm function definition |
🧩 🔟 Example DMN XML Snippet
Then, in your decision table:
👉 Watch "Create Function in DMN and Use It in Decision Table" in Action:
Here’s a short demo video to help you understand how to call functions inside DMN tables in jBPM:
YouTube: Learn IT with Shikha
🏁 Conclusion
🚀 DMN functions in jBPM allow you to modularize and reuse logic across decision tables.
They make your decision models cleaner, faster, and easier to maintain.
By combining BPMN (process) and DMN (decision) — with reusable FEEL functions —
you bring both intelligence 💡 and flexibility 🔄 to your business automation.
💼 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).
📧 Contact: ishikhanirankari@gmail.com | info@realtechnologiesindia.com
🌐 Website: IT Trainings | Digital metal podium
Comments
Post a Comment