◷ 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.
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:
- You need to keep modifying the flow – Maintainability
- 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.
- Router Decision Table (Orange) will decide the address of the next Decision Table to execute. Let’s call that dtAddress.
- The Place Holder DT node is the placeholder 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 were 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 placeholder 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:

- Dynamic Routing: Select this option
- Url: A string value that is going to be based on the dtAddress parameter that your Router Decision Table sets (i.e. ‘CountryTables/{countryTable}’)
Impact
- Easier maintenance: As you need to add more Decision Tables based on your scenario:
- You add a new Decision Table in the DTs folder.
- Add a new line in Router Decision Table to register your new DT
- 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 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.