Can a Decision Table be dynamically invoked?
Do you want to decide at the time of execution which Decision Table to invoke? Well, who doesnt like dynamic invocation? :). It is a powerful feature to have.
Consider the scenario:
A Courier company decides the rates based on the type of the courier(normal, expedited and ground).
If there are ‘n’ types of courier, then n rules and n decision tables is what we need. Each one of the rule checks for the type of the courier and calls the corresponding decision table. All the rules have similar conditions(type of courier) and similar actions(evaluate ‘this’ decision table). Well, a perfect scenario for a decision table (set of similar conditions and actions). Also, if there are lot of such types, you will end up having a lot of If-Then rules and it starts getting messy.
If the BRMS provides you the capability to dynamically invoke a decision table, which BRMS in CE 7.11 does, then you will have 1 rule and n+1 decision tables. The new decision table assigns the decision table to fired based on the type of the courier. The rule will just evaluate this decision table first and then dynamically invokes the next decision table. Isnt that cool?
Now, how do I model it?
- Create a variable of type “String”. For e.g “rateDT”.
- Create a decision table to assign this variable with the name of the decision table to fired based on the type of the courier. Here is a sample of how it looks:
- Create n decision tables with their corresponding rates.
- Create a rule that evaluates the “decider” decision table first and does the dynamic invocation next. Here is how this looks: