Skip to content
🚀 Play in Aletyx Sandbox to start building your Business Processes and Decisions today! ×

Creating your first DMN™ model from scratch

In this lab, we will walk through the steps required to create a DMN model from scratch starting using Aletyx Playground. This is a hosted instance of a customized version of the Aletyx Studio to provide a tailored introductory experience. This project will be used for the basis of the labs for the next 2 sections, so keep this in mind when working on it!

Using Aletyx Playground to create your model

  1. Navigate to https://playground.aletyx.ai and we will start creating a DMN model for the Vacation Days Decision. This lab provide some of the basics of a DMN decision and start getting you acquainted to DMN decisions built within Aletyx Playground and see how its DMN capabilities are laid out.

  2. From the Aletyx Playground landing page, you can create and edit various types of open-standards models in BPMN™, DMN and PMML™ using the editors here. We will be creating a DMN model for this lab, so to do this, click New Decision to create a new DMN model.

  3. You will now have an empty DMN model editor and can start working on your DMN model for designating the number of vacation days decision. Change the name at the top of the mode from Untitled to vacation-days (or whatever you want to call it).

Basics of DMN modeling - A Top/Down or Bottom/Up Approach both work here!

Now that the model is created, we need to create the base of the model. Our model can be designed from a top down approach or bottom-up given that we know most of the decision as it stands right now. There is a base level of days that will be used and three extra days cases that can be created. We also know that there are two inputs for the decisions - Age and Years of Service.

  1. Since we know most of the decision design up front, let's get started quickly!

  2. We know that we can put 2 input nodes (the ovals) and four decision nodes (the rectangles) onto the DMN designer area. You can drag and drop these from the left hand side and start changing the names.

    Tip

    This can be done by double clicking the name of each node (double click New Input Data and then change the name, same with the New Decision) or by using the properties menu by pressing either i on your keyboard when clicked on the node you want to change or clicking the i button in the top right of the DRD editor.

    DMN nodes on DRD showing modeling

    Input Node 1: Age
    Input Node 2: Years of Service
    Decision Node 1: Base Vacation Days
    Decision Node 2: Extra days case-1
    Decision Node 3: Extra days case-2
    Decision Node 4: Extra days case-3
    
  3. Now that we have the names of the nodes, we need to modify the contents within the nodes. You will do this by clicking on the appropriate node and clicking on the i button to open the properties panel (you can also press the i key on your keyboard to instantly open it as well). This can also be edited by using the pull down above the node for quicker change, the properties panel can also provide extra context if needed.

    Property GIF Change

  4. For each input node do the following configuration: Age - Data Type: number Years of Service - Data Type: number

    After this is done, we will work on the Decision nodes. Each one will have a Data type of number.

    Tip

    Just to note as we’re working on this, everything is stored locally in the browser storage, so you’re not having to press a combination of keys to save your work while you go - the editor is constantly in motion and saving while you're working with it. These are all stored locally, later we will get to how this interaction works with Git.

  5. Now we need to connect the Age and Years of Service input nodes to our Extra days case-1, Extra days case-2 and Extra days case-3 decision nodes (note we’re not connecting to Base Vacation Days and this will be explained later!). A good practice with DMN model design that Aletyx Studio allows is the use of the DMN Runner to see how your model is evolving while you’re working on it. If you press Run just above the editor, you will start seeing the model interact as the model changes. To do this, when your cursor hovers over the input node (Age or Years of Service), you will see an icon that is an arrow, this is the Information Requirement arrow that we will use to make it so that the Extra days case-1, Extra days case-2 and Extra days case-3 cases all require both the Age and Years of Service inputs.

    Age with Information Requirement Arrow

    Click to see the process in action Demo of the process

Building Extra Days Case-1

The first Extra days case is modeled by the scenario: “Employees younger than 18 or older than 60 will receive an extra 5 days or greater than 30 years of service will receive 7 days”. To implement this we will be building a decision table to model this logic, note that our decision table is going to be using the Age and Years of Service that we are taking from the input nodes.

Click to see a preview of Extra Days Case-1 Demo of Extra Days
  1. To create the decision table, click the Extra days case-1 node and select Edit just below the box to open the decision editor.

  2. From here, you will set the expression type to a Decision Table and then enter the following rows on the decision table.

  3. The hit-policy of the decision table is by default set to U, which means Unique. This implies that only one rule is expected to fire for a given input. In this case however, we would like to set it to Collect Max, as, for a given input, multiple decisions might match, but we would like to collect the output from the rule with the highest number of additional vacation days. To do this, click on the U in the upper-left corner of the decision table. Now, set the Hit Policy to Collect and when you click this, it will ask the Aggregator function to use, select MAX so you pull the largest value from the table. This will allow all rules on the table to fire and whichever is the largest to be the chosen value. This can be tested with various test scenarios using the run immediately while writing by putting some test data that would trigger the scenario. You will see these executions under the Extra days case-1 on the right side of the DMN runner’s outputs. Also note, that if you add an extra row to the table after creating it, you can copy the two rows below and paste them as you would into a spreadsheet as they're in the format you need to work!

    Age Years of Service Extra days case-1 Annotation
    <18, >=60 - 5 "Less than 18 or older than 60"
    - >30 7 "More than 30 years of service"
  4. Now you may have noticed that there were situations that didn’t return a value, but also left it at null when you were testing. To avoid issues with a null, we can set a default value on the output column, which is great in the otherwise situations. To do this, you will click the column header of Extra days case-1 and open the property panel by clicking the i in a circle button on the name of the decision header. After doing this, scroll down in the properties panel looking for Default Output Entry. Since we’re just changing the value of the column on default, there is no expression language that has to be added, but can instead just set the value equal to 0. Once you leave the Content box, you will see the decision itself react.

    How to set default to 0 Demo of Extra Days

  5. After this rule is done, click Back to Diagram.

Building Extra Days Case-2

A lot of the same steps from before are going to be repeated for Extra Days Case-2, so let's jump right in!

Click to see a preview of Extra Days Case-2 Demo of Extra Days
  1. To implement the second use case, Extra days case-2, click its decision node and select Edit to open the decision editor.

  2. This will give you the decision editor where you will need to click on Select expression and select Decision Table. From here the table will be autopopulated with the columns, same as before since they are connected as a information requirement to the node causing the editor to make it prepopulated.

  3. This time the rule is that there are an additional 4 days for more than 30 years of service or an additional 3 days for those greater than 60. Same as before as well, it will be a Collect Max and a default value of 0. Also, be sure to change the Hit Policy from Unique to Collect Max. Be sure to set the default of Extra days case-3 to 0 as before.

Age Years of Service Extra days case-2 Annotation
>=60 - 3 "Older than 60"
- >30 4 "More than 30 years of service"
  1. After this is completed, click Back to Diagram so we can add the last extra days case to Extra days case-3.

Building Extra Days Case-3

This will be done with the case that based on years of service being between 15 and 30 you get 3 extra days of vacation or if at least 45 you get 2 more days. Same as before, all default cases are set to 0.

Age Years of Service Extra days case-3 Annotation
- [15..30] 3 "Between 15-30 years of service"
>=45 - 2 "Older than 45"
  1. This rule will be setup the exact same way as the other ones. You will edit the Extra days case-3 decision and add the conditions for between 15 and 30 years of service for 3 days and if the Age is above 45 for 2 days. Make sure to set the default back to 0 as before with Extra days case-1 and Extra days case-2.
Click to see a preview of Extra Days Case-3 Demo of Extra Days
  1. Click Back to Diagram to return back to the Diagram to move to the next section

Summary of the Extra Days Cases

There’s an important component about the three extra cases that we want to visit first though before moving on. You will notice that all three had both input nodes connected to them and from that connection, the DMN editor built the columns that would be used as condition columns and the decision node itself was used as the output column for each specific column. This greatly helps with the building of your decisions. The reason being that as a Decision Requirements Diagram, the decision node uses the inputs to drive the decision based on the information requirements you give it, you will see as we added more components to the diagram, it continued to execute them once the requirements were met. This is an essential part of DMN. Now that the extra days cases decisions are each completed, we can revisit Base Vacation Days.

Creating Base Vacation Days

The last base decision that we need to create is the Base Vacation Days decision. On the base Decision Requirement Diagram and click on Base Vacation Days and click Edit. On the node’s “Select expression”, we’re going to select Literal and input 22 as the base number of vacation days is 22.

Age with Information Requirement Arrow

Click to see a preview of Base Vacation Days Demo of Base Days

Bringing the decisions together

You will notice that after the 22 is put in on the previous decision, that it executes the Base Vacation Day decision as soon as it is completed. This is because this decision has no requirements on the age or years of service, if you were to delete the data from Age and Years of Service, the decision for Base Vacation Days would remain at 22 and the others would return null as the data is assumed to be null/empty in this situation. This is the power of DMN at work, the decisions that can be made at the time of execution will be made based on the requirements met. So as more data is obtained (Age/Years of Service), the nodes attached to it will be executed since their requirements are met. However, now that we have these nodes all executing, we would like to get to a final decision that is made when the 4 components of the decision are executed.

Building Total Vacation Days

  1. On the diagram, we are going to create one more decision that we’re going to call Total Vacation Days. To do this, click on any of the four decision nodes, and you will see a means to add a connection to another decision node. Click on this and drag it to an open area on the top of the Decision Requirement Diagram.
Click to see a preview of Drawing Total Vacation Days Demo of Total Vacation Days
  1. Once this is added to the diagram, you will connect the remaining 3 decision nodes using the line with the arrow head on it to connect them. This will make it so that the Total Vacation Days decision requires all 4 nodes to be activated to be able to execute the decision.

  2. Now for this decision, it is going to be the Base Vacation Days plus the higher of the two between case-1 and case-3 plus the days from case-2. The feel expression from this would look like:

Base Vacation Days + max(Extra days case-1, Extra days case-3) + Extra days case-2
Click to see a preview of Total Vacation Days Demo of Total Vacation Days