1. Home
  2. Dynamic routing

Dynamic routing

◷ Reading Time: 6 minutes

Introduction

Dynamic routing is a capability that allows routing of the execution down a specific path based on some conditions (parameters). These conditions will be evaluated at runtime, not at design time. This technique allows you to make your flow orchestration simpler to understand and easier to maintain.

Dynamic routing can be applied on Decision Requirement Diagram (DRD), Natural Language (NL) and Sub-Flow as well as Decision table (DT). In this post, we will just show the DT, but the pattern can be applied in the same way on the other types of logic.

Sample Scenario

Let’s say you have a flow that decides based on the name of a ‘Program’ what type of discount a customer is eligible for, as well as a decision point (orange diamond node) that routes the execution to a specific Discount Decision Table for the Program:

As your Program grows you need more and more Discount Decision Tables under the decision node. There are some key challenges to achieving that:

  1. You need to keep modifying the flow – Maintainability
  2. Your flow keeps growing and becomes harder to understand

Solution

Flow

Dynamic routing allows you to change the above flow to a simpler one:

This flow contains only two Decision Tables, no matter how many Programs you add or remove from your business logic.

  1. Router Decision Table (Orange) will decide the address of the next Decision Table to execute. Let’s call that dtAddress.
  2. The Place Holder DT node, which is the place holder for a selected (picked) decision table to be executed.

In this solution, as the numbers of the programs grow, you need to just add a new Decision table for the new program, then add a new line in the Router Decision Table to tell the flow where to pick the new Decision Table.

Logic documents

You simply organize all of your Decision Tables for the program into a folder and the main flow that is described above.

Router

The Router is just a simple Decision Table that allows you to register a name of a target Decision Table based on some criteria (parameters that matter to you for choosing one Decision Table over another). In this instance, that is the program name.

Place Holder Decision Table

The place holder Decision Table is the second one in the flow. It will be using the resolved address from the Router to load the Decision Table document (e.g., The one related to the program name).

To configure that, you need to select the second Decision Table and set the properties as shown below:

  1. Dynamic Routing: true
  2. Url: A string value that is going to be based on the dtAddress parameter that your Router Decision Table sets (i.e., ‘DTs\\{dtAddress}’)

Impact

  1. Easier maintenance: As you need to add more Decision Tables based on your scenario:
    1. You add a new Decision Table in the DTs folder.
    2. Add a new line in Router Decision Table to register your new DT
  2. Adding default behavior for unknown criteria (i.e., unknown Program name). You can simply add the last rule in Router Decision Table with an empty condition and a default Decision Table as a catch-all for decisions.

Publishing a Package with Dynamic Routing

Using Package Builder

You can use the package builder to publish the packages with dynamic routing.

Under Package View, click on + icon to add the files.

In this example (Sample Project 2), you will have to add all the files under the folders CountryFlows and CountryTables.

After adding, the files will appear as below.

Every time you publish, if required to manually add the files.

Using Publish Profile

When you use a publish profile, it is important to create the areas exactly similar to the folder structure of your project. This is the recommended way as it requires building the profile only once and then you can deploy as you want.

In this example (Sample Project 2), you will have to add all the files under the folders CountryFlows and CountryTables similar to the project folder structure.

Sample Projects

Project 1

This project (Customer Eligibility.zip) can be downloaded using the attachment at the end of the page.

The output will show whether the company is eligible or not.

Project 2

This project (DRD_Dynamic_Routing.zip) can be downloaded using the attachment at the end of this page.

At the end of the project, it will show whether the company is valid to apply for an award. The selection criteria are based on the country and it will show how to set the dynamic route to select the route according to the country.

Sample input JSON files are in the folder DRD Dynamic Routing\sampleJSON.

Updated on July 8, 2020

Article Attachments

Was this article helpful?