Understanding the Business Requirements
Before modeling, let’s understand what we’re trying to achieve. Our vacation days calculation follows these business rules:- All employees receive a base allocation of 22 vacation days for their Base Vacation Days
- Three additional day categories exist:
- Extra Days Case 1:
- Employees younger than 18 or older than 60 get 5 extra days
- Employees with more than 30 years of service get 7 extra days
- Extra Days Case 2:
- Employees older than 60 get 3 extra days
- Employees with more than 30 years of service get 4 extra days
- Extra Days Case 3:
- Employees with 15-30 years of service get 3 extra days
- Employees aged 45 or older get 2 extra days
- Total vacation days are calculated as:
- Base days + maximum of (Case 1, Case 3) + Case 2
Setting Up Aletyx Playground
- Navigate to Aletyx Playground in your browser
- From the landing page, click New Decision to create a new DMN model
- You’ll be presented with an empty DMN model editor. This is where we’ll design our decision model
- First, change the name of the model from “Untitled” to “vacation-days”
Creating Input Nodes
Our decision model relies on two inputs: the employee’s age and their years of service.- Drag an Input Data node (oval shape) from the left palette onto the model editor
- Double-click the node and rename it to “Age”
- With the node selected, open the properties panel by clicking the “i” icon in the top right or pressing the “i” key
- Change the Data Type to “number”
- Repeat steps 1-4 to create another Input Data node named “Years of Service” with the data type “number”
Creating the Base Vacation Days Decision
First, let’s define the base vacation entitlement that all employees receive:- Drag a Decision node (rectangle shape) onto the model editor
- Name the node “Base Vacation Days”
- Set its Data Type to “number”
- Click on the node and select Edit to define the decision logic
- In the expression editor, select Literal expression as the expression type. For reference on the different expressions see the below image with annotations or refer to the Select Expression Reference
What each numbered expression type is
What each numbered expression type is
- Literal Expression — The simplest expression type. Used for direct values, mathematical operations, or simple FEEL expressions. Example:
Base Premium * Risk Factor - Relation — Creates a table structure for organizing data. Unlike a decision table, relations don’t contain logic but represent structured data with columns and rows. See the Relation Reference.
- Context — Defines a set of key-value pairs (named variables) that can be referenced within the context. Useful for multi-step calculations that build on previous values. See the Context Reference.
- Decision Table — The most widely used DMN expression. Organizes conditions (inputs) and conclusions (outputs) in a tabular format with hit policies determining how rules are applied. See the Decision Table Reference.
- List — Creates an ordered collection of values or expressions. Each list item can be a different type of expression, allowing for complex collections. See the List Reference.
- Invocation — Calls a Business Knowledge Model (BKM) or function defined elsewhere in the model. Parameters can be passed to the function being called. See the Invocation Reference.
- Function — Defines a reusable function with parameters. Can contain any FEEL expression type and be used within other expressions through Invocation. See the Function Reference.
- Conditional (If/Then/Else) — Creates branching logic with if, then, else statements. Allows for different results based on specific conditions being met. See the Conditional Reference.
- For Loop — Iterates over items in a list or collection, applying an expression to each item. Useful for transforming collections or aggregating values. See the For Loop Reference.
- Some — Tests when a condition is true for at least one item. See the Some Reference.
- Every — Tests if a condition is true for every item in a collection. Returns a boolean result based on whether all items satisfy the condition. See the Every Reference.
- Filter — Filters a collection based on a given condition. See the Filter Reference.