Skip to main content

Part 2: Decision Service

In the first part of this modeling guide we created the process 'Loan Request Approval' that used the outcome of a DMN decision table. We will reuse this process but in this part we will create a DMN decision service that consists of multiple DMN decisions with decision tables. The Decision task will execute the DMN decision service instead of DMN decision table. The process will act on the outcome of the decision service.

The process 'Loan Request Approval'

process overview

We will modify the following parts of the process;

  • Add an input field to the Loan Request Intake Form
  • Create a DMN decision service that will be executed by the Evaluate Loan Request Decision Task

The additional field in the Loan Request Intake Form will be used in one of the decisions in the decision service. In the new DMN decision service an additional decision table will be executed (in addition to the existing table). The result of both tables will be used to evaluate a new DMN decision. The result of this decision will be the result of the decision service and made available to the process.

Step 1: Modify the 'Loan Request Intake Form'

In Flowable Design choose the workspace that holds the Loan Request App and select it. Then from the App select the Loan Request Intake form.

In the Form Designer, we will add the following field;

  • type: 'Number', name: Credit Score, id: creditScore

modify intake form

The form is done and is saved by selecting the Save button in the toolbar. After the form is saved, navigate back to the app by selecting the Close button in the toolbar.

Step 2: Create the DMN decision service

A DMN decision service has two sections; the upper part; the output decisions section and the lower part; the encapsulated decisions section. The results of the decisions that are part of the encapsulated decisions section can be used in other decision service decisions but are not part of the output of the decision service. The results of the decisions that are part of the output decisions section compose the result of the decision service.

The new decision service will consist of 3 decisions with decision tables;

  • 2 encapsulated decisions;
  • a decision using the (already existing) Evaluate Loan Request decision table
  • a decision with a 'Evaluate Credit Score' decision table
  • 1 output decision;
  • a decision with a 'Evaluate Loan Eligibility' decision table

The 'Evaluate Credit Score' decision table will evaluate the credit score and result in a credit rating. Both the credit rating and the result of the Evaluate Loan Request decision table will be used as inputs for the Evaluate Loan Eligiblity decision table. This decision table will 'overrule' the approvalState for specific credit scores.

Step 2A: Modify the Evaluate Loan Request decision table

The existing decision table Evaluate Loan Request will not be an output decision and thus will not be used as the result of the decision service. For clarity we will be rename the output of this decision table.

Select the Evaluate Loan Request decision table in the Loan Request App.

The DMN Decision Table Editor will be opened.

Modify the column label and variable name of the output by selecting the Approval State column header and choosing Edit column.

  • Column label: Pre Approval State, Variable name: preApprovalState.

modify decision table

Please note that since we're using the variable 'approvalState' in the conditional expressions ${approvalState == 'APPROVED'}and ${approvalState == 'APPROVED'}of the sequenceFlow in the 'Loan Approval App', we have to change it to ${preApprovalState == 'APPROVED'} and ${preApprovalState == 'APPROVED'}.

Save the changes by selecting the Save button. Then save the decision table by selecting the Save button in the toolbar. After that close the editor and return to the App by selecting View models from the Actions menu.

create new decision service

Step 2B: Create the 'Evaluate Loan Request Decision Service' model

Once back to the Loan Request App click the Create button and select Decision service for the model type. Name it Evaluate Loan Request Decision Service and give it the key evaluateLoanRequestDecisionService.

create new decision service

Finally, select the Create button.

Step 2C: Model the 'Evaluate Loan Request Decision Service'

The DMN Decision Service Editor is automatically opened after creating the decision service.

Start by creating an encapsulated decision by dragging the Decision element to the lower part of the decision service.

create new decision service decision

Select the Evaluate Loan Request as the Decision table reference. This is done by selecting the decision then selecting Decision table reference, and then in the resulting popup click the link to an existing one link and choosing the Evaluate Loan Request decision table.

Click the Finish button and provide 'Evaluate Loan Request' as the name of the decision.

Step 2D: Create the Evaluate Credit Score decision table

Add another encapsulated decision by dragging the Decision element to the lower part of the decision service.

Provide 'Evaluate Credit Score' as the name of the decision.

Create a new decision table by selecting Decision table reference and then in the resulting popup providing a Name and Key.

Provide the following info;

  • Name: Evaluate Credit Score, Key: evaluateCreditScore

Create the decision table by selecting the Create button followed by the Finish button.

After the DMN Decision Table Editor is opened create the following decision table.

Inputs;

  • Column label: Credit Score, Variable name: creditScore, Variable type: number

Outputs;

  • Column label: Credit Rating, Variable name: creditRating, Variable type: string, Output values; BAD, FAIR, and EXCELLENT

Rules;

  1. Credit Score: < 500 / Credit Rating: BAD

  2. Credit Score: < 600 / Credit Rating: FAIR

  3. Credit Score: >= 700 / Credit Rating: EXCELLENT

create new decision service decision

For the hit policy choose 'UNIQUE' to determine that the result of the decision table is then and only then valid, when one rule is valid.

Step 2E: Create the Evaluate Loan Eligibility decision table

Back to the Evaluate Loan Request Decision Service add an output decision by dragging the Decision element to the upper part of the decision service.

Provide 'Evaluate Loan Eligibility' as the name of the decision.

Create a new decision table by selecting Decision table reference and then in the resulting popup providing a Name and Key.

Provide the following info;

  • Name: Evaluate Loan Eligibility, Key: evaluateLoanEligibility

Create the decision table by selecting the Create button followed by the Finish button.

After the DMN Decision Table Editor is opened create the following decision table.

Inputs;

  • Column label: Pre Approval State, Variable name: preApprovalState, Variable type: string

  • Column label: Credit Rating, Variable name: creditRating, Variable type: string

  • Outputs;

  • Column label: Approval Rating, Variable name: approvalRating, Variable type: string, Output values; DECLINED, REVIEW, and APPROVED

Rules;

  1. Pre Approval State: == DECLINED / Credit Rating: == EXCELLENT/ Approval State: REVIEW

  2. Pre Approval State: == DECLINED / Credit Rating: != EXCELLENT/ Approval State: DECLINED

  3. Pre Approval State: == REVIEW / Credit Rating: == FAIR/ Approval State: DECLINED

  4. Pre Approval State: == REVIEW / Credit Rating: != FAIR/ Approval State: REVIEW

  5. Pre Approval State: == APPROVED / Credit Rating: == BAD/ Approval State: REVIEW

  6. Pre Approval State: == APPROVED / Credit Rating: != BAD/ Approval State: APPROVED

create new decision service decision

For the hit policy choose 'UNIQUE' to determine that the result of the decision table is then and only then valid, when one rule is valid.

Save the decision table and select View models from the App's Action menu.

Step 2F: Provide the Information Requirements

Open the decision service editor for the Evaluate Loan Request Decision Service.

In order to specify what decision results can be used in other decisions we have to provide what decision is an Information Requirement of another decision.

Select the Evaluate Loan Request decision and select the arrows icon on the right-hand side of the selected decision.

provide the first information requirement

Drag the arrows icon to the Evaluate Loan Eligibility decision.

Do the same for the Evaluate Credit Score decision.

provide the second information requirement

After this the decision service is ready and can be saved and closed.

Decision service: Deploy the App

To execute the process, and it's decision service we need to redeploy the App containing the updated artifacts.

Navigate to the Loan Request App and deploy the App by selecting the Publish app model from the App's Action menu. Confirm by selecting the Publish button in the resulting popup.

deploy updated app

Decision service: Execute the Process

Flowable Work is used to demonstrate the process and two different scenarios are showing the various potential outcomes of the decision service.

Scenario 1

In Flowable Engage select Work>Create new in the left menu. Select the Loan Request Approval Process from the Loan Request App.

create new process

Select Continue.

A process instance is started and the process execution halts at the first step; the Loan Request Intake user task.

Select the task in the Open tasks list.

The form is presented. In this first scenario, enter the following data:

name: Requester Three

age: 20

country: The Netherlands

amount: 200.000

credit score: 800

input scenario 1

With a lower credit score than 700 the request would in this case be DECLINED. But because of the credit rating EXCELLENT the request was marked for REVIEW.

result scenario 1