Business rules execution from DMN in Signavio Process Governance

Written by Peter Hilton | 12 min read
Published on: September 22nd 2016 - Last modified: November 13th, 2020

Signavio Process Governance’s integration with the SAP Signavio Process Manager takes business rules from modeling to execution

This article is a tutorial demonstrating how you can use SAP Signavio Process Manager to define business rules in a Decision Model & Notation (DMN) model, and then use Signavio Workflow Accelerator for business rules execution. DMN gives you a way to define business rules in a separate model and prevent business logic from making a business process model unnecessarily complex.

Modeling business rules with DMN

To keep things simple, for this tutorial, you’ll use a simple price calculation example. This is a typical use for business rules, which often calculate a numeric result based on a number of input variables. Price calculations are often notoriously complex, but this example only depends on the price per unit, the number of units, and a calculated discount based on the number of units, as shown in this DMN model.

In this model, ‘Unit price’ and ‘Number of units’ are input values. ‘Discount’ is a business decision that uses ‘Number of units’ as input, and ‘Total price’ is another business decision that uses both input values and the ‘Discount’ decision as input.

Creating the rules model in the SAP Signavio Process Manager

To start, open the Signavio Explorer. On the ‘New’ menu, select the ‘Business Decision Diagram (DMN 1.1)’ option, to create and open a new DMN model diagram..

Create the model from the diagram (above) by dragging ‘Decision’ and ‘Input data’ shapes from the ‘Shape Repository’ palette on the left. To draw the arrows, select a shape and drag the small arrows icon, which appears next to the shape, to the shape you want to connect to.

Now you have a basic DMN model that shows the input data, the decisions, and the dependencies between them. The next step is to set the correct data type for the two inputs.

  1. Select the ‘Unit price’ input data shape in the diagram.
  2. Open the ‘Attributes’ panel on the right.
  3. Set the ‘Value domain’ to ‘Number’.
  4. Set the ‘Unit’ to ‘Currency’
  5. The the ‘Monetary unit’ to ‘EUR’.

Repeat steps 1-3 for the ‘Number of units’ input, to set its domain to ‘Number’. Specifying the value domain makes it possible to use the numbers in calculations, which is the next step.

Adding a decision table

Now that you have specified that the ‘Number of units’ input is a number, you can use it to configure the ‘Discount’ decision table.

To add this table to the DMN model in the editor, complete the following steps.

  1. In the diagram, click the decision table icon at the top-left of the ‘Discount’ shape.
  2. On the ‘Decision logic: Discount’ dialogue, double-click the ‘New Output’ column heading and change it to ‘Discount’.
  3. Under the ‘Discount’ column heading, double-click the ‘Text’ heading.
  4. On the ‘Column configuration’ dialogue, set the ‘Value domain’ to ‘Number’.
  5. Set the ‘Number unit’ to ‘Percentage’, and click ‘Save’.
  6. At the top-left of the table, click the ‘U’ to open the table configuration dialogue.
  7. On the table configuration dialogue, change the hit policy to ‘First (single)’, so you can specify the discount according to the first number of units that matches.
  8. Double-click in the left-hand side of the first cell in row 1, and on the operator list, select ‘< (less)’.
  9. In the right hand side of the cell, double-click and enter the number ‘100’.
  10. In the ‘Discount’ column, double-click and enter the percentage ‘0’.
  11. In the annotation column, double-click and enter ‘No discount’.
  12. Click ‘Add new row’ and repeat steps 8-10 to add the remaining discount rules, as shown in this screenshot.

This decision table defines the discount for each number of units; each row in the table is a ‘rule’. The ‘First’ hit policy, shown as an ‘F’ in the top-left corner, means that each rule will be evaluated until one matches the ‘Number of units’ input value. The first match will determine the ‘Discount’, which is the output value for this decision.

Note that the last rule is ‘Number of units ⩾ 1000’, which will match the number of units if none of the previous rules match, so that at least one rule matches.

Adding an expression-based rule

Calculating the discount involved selecting one discount rule from a table. However, to calculate the total price, including the discount, you need to configure an arithmetical expression.

To define the total price based on the inputs and the discount, configure the ‘Total price’ decision to use an expression.

To add this table to the DMN model in the editor, complete the following steps.

  1. In the diagram, click the decision table icon at the top-left of the ‘Discount’ shape.
  2. On the ‘Decision logic: Total price’ dialogue, on the left select ‘Literal Expression’.
  3. Use the pick list to change the expression type from ‘Free text’ to ‘Expression’.
  4. Click in the text input field, and select the ‘Number of units’ variable from the menu.
  5. Still in the text input field, type a ‘*’ (an asterisk) and select ‘Unit price’.
  6. Type ‘* (1 - ’, select Discount, and type ‘)’ to complete the expression.
  7. Select ‘Apply and close’ to save changes.

The DMN model is now complete, so you’re ready to create the BPMN model and link it to the DMN diagram.

Linking business rules to a process model

To use the ‘Calculate total price’ DMN model, you need to add it to a BPMN process model as a business rule task.

Create the ‘Send price quotation’ model in SAP Signavio Process Manager by creating a new BPMN 2.0 diagram with a sequence of three tasks, each with the given name and task type.

  1. Calculate price (Business rule)
  2. Check total (User)
  3. Send quotation (Send)

To link the ‘Calculate price’ task to the DMN model as follows.

  1. On the ‘Attributes’ panel, set the ‘Task type’ to ‘Business rule’.
  2. In the ‘Decision logic’ attribute value, select the browse button.
  3. On the ‘Establish link’ dialogue, select ‘Use existing diagram’.
  4. Select the ‘Calculate total price’ DMN model from your workspace, and select ‘Link diagram’.

Now you have a BPMN process model that links to a DMN business rules model and is now ready for execution.

Business rules execution

To execute the business rules in ‘Calculate total price’ DMN model, you need to execute the linked BPMN model.

Transferring the BPMN model to Signavio Process Governance

In Signavio Explorer, select the ‘Send price quotation’ BPMN model, and on the Signavio Workflow menu, select ‘Execute in Signavio Workflow’. If you don’t see this menu, ask your system administrator to link the workspace to Signavio Process Governance.

On the confirmation dialogue box, select ‘Transfer’ to copy the BPMN model to Signavio Process Governance:

When the model has transferred successfully, select ‘Open the workflow in Signavio Process Governance’:

This will open the model in Signavio Process Governance’s process editor.

Preparing the process model for execution

When you open the process in Signavio Process Governance’s process builder, the ‘Actions’ tab shows the model that you created in the SAP Signavio Process Manager. However, the process is not yet ready for execution; you still need to add the forms for entering and viewing process data.

First, select the ‘Trigger’ tab, so you can add a form trigger that will capture input data for the process.

To add the trigger form, complete the following steps.

  1. On the process builder’s ‘Trigger’ tab, select ‘When a form is submitted’ to add the trigger form.
  2. On the right-hand side, select ‘Money’ to add a money type field.
  3. Enter the label ‘Unit price’.
  4. Select ‘Number’ to add the second field, and enter the label ‘Number of units’.

The next step is to configure the DMN Rule Task input variables, by mapping the two form fields to the business rules. Select the ‘Actions’ tab, then select the ‘Calculate price’ business rule task.

On the business rule task’s configuration panel, the ‘Inputs’ tab shows the two inputs to the DMN model, ‘Unit price’ and ‘Number of units’. For each input, select the field next to the input and then select the form field with the same name.

Next, use the ‘Outputs’ tab to configure the process variable that the rule task will create for the DMN model’s ‘Total price’ output.

The ‘Outputs’ tab automatically maps the output to a variable with the same name, so you do not have to change the configuration here.

Next, configure the ‘Check total price’ user task to show the calculated total price.

To add the ‘Total price’ field to the form, complete the following steps.

  1. In the process editor, select the user task to open its configuration panel.
  2. Select the ‘Form’ tab.
  3. On the right hand side, select the pick list of existing fields, and select ‘Total price’ to add the field to the form.

Finally, at the top-right of the page, select ‘Publish changes’ to create a new version of the process model that includes the forms and business rule task mappings. Now the process is ready for execution.

Executing the process

To execute the process, on the process builder’s ‘Versions’ tab or in the ‘Processes’ list, select ‘Start new case’. This shows the start form that you defined earlier, where you can enter values for ‘Unit price’ and ‘Number of units’.

Enter values on the form, then select ‘Start new case’ to create a new ‘Send price quotation’ case. Signavio Process Governance executes the business rule task automatically, so you can check the result immediately.

On the ‘Send price quotation #1’ case view, select the ‘Check total price’ task to open the task view. The task view shows the form that includes the ‘Total price’ field, this is populated with the result of the business rules execution.

Congrats, you’re done! The only thing left to do is to select ‘Done’ to complete the task, and execute the ‘Send quotation’ task to send an email. Don’t worry, though: it won’t actually send an email anywhere if you didn’t configure the email task.

You’ve now seen an end-to-end example of defining and executing business rules using Signavio’s Process Transformation Suite. If you don’t already have access to Signavio’s products, contact us to find out how you get access to integrated business process and rules for both modeling and execution.

Published on: September 22nd 2016 - Last modified: November 13th, 2020