Decision Table commands

Print Friendly, PDF & Email

◷ Reading Time: 3 minutes

An Xml document can represent a Decision Table. The following table shows the available commands to model a Decision Table using Xml Language.

DecisionTable

Main Decision Table body that contains its definition

Summary

This is the main container to define a Decision Table. This element in general is grouped into three sections:

  1. Declaration of Input, Output, and Import
  2. Definition of Columns
  3. Data for the Decision Table

Parameters

  1. name
    1. Description: The name of a decision
    2. Mandatory: Yes
    3. Type: Any value (String)
  2. type
    1. Description: Description: Type of engine to be used
    2. Mandatory: No
    3. Type: Validation, Decision
  3. processAll
    1. Description: If true all the rows in the decision table will be executed
    2. Mandatory: No
    3. Type: Boolean (true/false)
  4. multiHitPolicy
    1. Description: Manages how multiple results can be ordered
    2. Mandatory: No
    3. Values: None, OutputOrder, RuleOrder
  5. aggregation
    1. Description: Aggregates multiple results into one using a function
    2. Mandatory: No
    3. Values: Collect, Sum, Min, Max, Count, Average
  6. function
    1. Description: Defines an expression that will be evaluated after Decision Table execution is finished
    2. Mandatory: No
    3. Values: An Expression

Internal Commands

Declaration

This is command is used to define decision Parameters.

Columns This command defines Name, Condition and Action of rules template within a decision

Data

This section defines the values of rules based on a template that is defined in Columns.

Sample

<DecisionTable name="Define potential occupant injury rating" processAll="False">
</DecisionTable>

Glossary

A glossary is a dictionary that defines all the business terms and their domains.

Use this link to see the full list of glossary commands.

Columns

This command structures the columns of a Decision Table.

Parameters

  1. condition
    1. Description: Name of a Boolean variable that checks the continuation of the iteration condition
    2. Mandatory: Yes
    3. Type: String (name of variable

Sample

<Columns> 
    <Condition name="Min" expression="person.Age>=$value" /> 
</Columns>

Condition

This command defines a column of a Decision Table that holds a template for validating a condition. This is an expression that uses template mechanisms. $value refers to values of the cells of this column, as shown below.

A condition can participate in the discrimination network when the discriminator attribute is set to true.

Parameters

  1. name
    1. Description: The name of a column
    2. Mandatory: Yes
    3. Type: String
  2. expression
    1. Description: Expression of the condition to be evaluated
    2. Mandatory: When no ‘term’ is defined
    3. Type: String (expression and template)
  3. term
    1. Description: Refers to a Glossary Term’s name
    2. Mandatory: When no ‘expression’ is defined
    3. Type: String (name of a term)
  4. discriminator
    1. Description: When a column is defined as a discriminator, true; otherwise false. (default is false)
    2. Mandatory: no
    3. Type: boolean (true or false)

Sample

<Columns> 
    <Condition name="Min" expression="person.Age>=$value" /> 
    <Condition name="Max" expression="person.Age<=$value"/> 
</Columns>

Action

This command structures the columns of a Decision Table as an action. Action can be in two types:

  1. Notice: To write a notice in a notification (set type to notice)
  2. Or using any expressions directly (e.g., call a method, assign a value). See Expression. (leave type empty)
Parameters

  1. name
    1. Description: Represents the name of the column
    2. Mandatory: Yes
    3. Type: String
  2. type
    1. Description: type of action. If this is not set then expression should use the full evaluation expression. For more information check Expression
    2. Mandatory: No
    3. Type: Notice (Obsoleted values: Set, Call)
  3. expression
    1. Description: The expression template of an action or notices message
    2. Mandatory: When no ‘term’ is defined
    3. Type: String (Expression)
  4. term
    1. Description: Refers to a Glossary Term’s name
    2. Mandatory: When no ‘expression’ is defined
    3. Type: String (name of a term)
  5. variable
    1. Description: name of the variable that the expression targets
    2. Mandatory: Yes if the type is set
    3. Type: String (parameter name)

Obsoleted: In ‘type’ parameter Set and Call are for legacy compatibility. Make sure you don’t use it in your models. To call a method or assign values to properties of parameters use Expressions.

Notice Action

  1. notice (only valid when type is set to ‘Notice’ )
    1. Description: specifies the type of notice message
    2. Mandatory: No
  2. notification (When notice action)
    1. Description: Allows grouping notices in different categories
    2. Mandatory: No
    3. Type: string (no space is allowed)
  3. useMessageId (When notice action)
    1. Description: specifies the values for notice messages will be used as messageId
    2. Mandatory: No
    3. Type: bool (true/false)

Array

When Action applies on array, below parameters are required:

  1. onArray
    1. Description: reference to the parameter/expression that is the source of array/collection
    2. Mandatory: Yes
    3. Type: Parameter name or expression
  2. elementName
    1. Description: reference to each individual element on the array/collection
    2. Mandatory: Yes
    3. Type: Parameter name

Sample

Action with no type specified as an direct expression:

<Columns>
  <Condition name="Min" expression="person.Age ge $value" /> 
  <Condition name="Max" expression="person.Age le $value" />
  <Action name="Title" expression="title = $value"/>
</Columns>

Action with type specified.

<Columns>
  <Condition name="Min" expression="person.Age ge $value" /> 
  <Condition name="Max" expression="person.Age le $value" />
  <Action name="Title" expression="title" />
</Columns>

Action with type of ‘Notice’ to write messages using Notification

<Columns>
  <Condition name="Product Exists?" expression="product.Found == $value" />
  <Condition name="Points > 20" expression="((product.Quantity * product.Point) > 20)" />
  <Action name="Error Message" expression="$value" type="Notice" />
  <Action name="Success Message" expression="$value" type="Notice" notice="Information" />
</Columns>

Name

This command defines the name of rule/logic in a Decision Table.

Sample

<Columns> 
    <Condition name="Min" expression="person.Age ge $value" /> 
    <Condition name="Max" expression="person.Age le $value"/> 
    <Name /> 
</Columns>

Priority

In Decision Table by default, all rules will be executed from top to down. For a complex Decision Table, this priority of execution can be changed by the priority column. The priority value in a row must have a numeric value, otherwise, it is considered as 0.

Sample

<Columns> 
    <Condition name="Min" expression="person.Age ge $value" /> 
    <Condition name="Max" expression="person.Age le $value"/> 
    <Priority /> 
</Columns>

GroupName

In a complex Decision Table, rules can be grouped in multiple different sections. This can be used to manage a complex decision behaviour in combination with a Priority column. When the rules require grouping and each group of rules has its own priority, groupNamecan be used.

Sample

<Columns> 
    <Condition name="Min" expression="person.Age ge $value" /> 
    <Condition name="Max" expression="person.Age le $value"/> 
    <GroupName /> 
</Columns>

Data

This command structures the data of a Decision Table. The data part of the table must be encapsulated by Row and then by Value element in the xml. Each value in the data section represents a positive condition, if a negative condition is required it should be prefixed by ‘not:’.

Decision Table supports iterating through items of a list and processes them. To do that, the on and childName parameter must be set.

Parameters

  1. on
    1. Description: Defines a list of items to iterate through
    2. Mandatory: No
    3. Type: Expression
  2. childName
    1. Description: Defines the name of parameter, each item in the list will be referenced
    2. Mandatory: Yes, when ‘on’ is defined
    3. Type: String (Parameter name)

Sample

<DecisionTable name="person growing state">
  <Declaration>
    <Define name="person" direction="In"/>
    <Define name="title" direction="Out"/>
  </Declaration>
  <Columns>
    <Condition name="Min" expression="person.Age ge $value" />
    <Condition name="Max" expression="person.Age le $value"/>
    <Action name="Title" type="set" variable="title" expression="$value"/>
    <Action name="Title" expression="person.SetTitle($value)"/>
  </Columns>
  <Data>
    <Row>
      <Value>0</Value>
      <Value>3</Value>
      <Value>infant</Value>
    </Row>
    <Row>
      <Value>4</Value>
      <Value>6</Value>
      <Value>kid</Value>
    </Row>
    <Row>
      <Value>7</Value>
      <Value>18</Value>
      <Value>teen</Value>
    </Row>
    <Row>
      <Value>19</Value>
      <Value>23</Value>
      <Value>young</Value>
    </Row>
    <Row>
      <Value>not: 24</Value>
      <Value>99999</Value>
      <Value>adult</Value>
    </Row>
  </Data>
</DecisionTable>

CallDecisionTable

This is an integration point between different engines and Decision Table definitions. When other rules require calls to a Decision Table they can use this command.

All output parameters of a decision will automatically be copied on the parent context.

Parameters

  1. contextMode
    1. Description: Set context behaviour to call to other rules and logic. If set to Shared, the current context will be used for the target rule. Otherwise a new one is created.
    2. Mandatory: Yes
    3. Type: String (Shared/New)

Internal Commands

DecisionTableSource

  1. uri
    1. Description: Where is the source of the external DecisionTable to be run?
    2. Mandatory: Yes
    3. Type: Physical file or RuleSet address

Sample

DecisionTable integrated into a Flow.

<Activity name="ActivityD">
  <CallDecisionTable contextMode="New">
    <DecisionTableSource uri="AgeTitle.xml" />
    <Param name="person" ref="person"/>
  </CallDecisionTable>
  <Transition name="tr6" to="end"/>
</Activity>

DecisionTable integrated into a Procedure.

<CallDecisionTable contextMode="Shared">
  <DecisionTableSource uri="AgeTitle.xml"/>
</CallDecisionTable>

Updated on July 31, 2019

Was this article helpful?

Related Articles