View Article

Create a Decision Table with One In Variable

By Xelence Documentation posted 02-07-2022 13:09

  

Introduction

A decision table is a representation of rules in tabular form. It is especially useful for a rule that makes many decisions based on multiple inputs.

This example is a very simple decision table just to demonstrate the interface. It calculates a discount based on the number of products ordered.

Prerequisites

The entity must exist.

Quick Steps
1 Click the Create New Item icon, then select the Object Type
2 Select the Rule Type
3 Enter the decision table details, then click Finish
4 Open the Parameters panel, then add the parameters
5 Enter the parameter details, then click OK
6 Enter Descriptions for the column headers
7 Enter the column header variables
8 Add desired conditions
9 Enter descriptions and expressions for the conditions
10 Save the decision table

Detailed Steps

Step 1. Click the Create New Item icon, select the Object Type, then select the Rule Type.

This opens a dropdown list from which you can select an object to begin its item wizard. The item wizard creates a file or files. 

The Object Type identifies the file the wizard will create. In this case it is Rule.

Step 2. Select the Rule Type.

The rule type identifies the type of rule the wizard will create. In this case it is Decision Table.


Step 3. Enter the decision table details, then click Finish.

The properties are:

  • Creation Type: Specifies the method by which the decision table is created.
  • Entity: Determines the attributes and properties available to the decision table.
  • Name (ID): This is the decision table's programmatic ID. This property is required.
  • Return Type: This is the data type of the result you expect the decision table to return (string, int, etc.).
  • NeoTrack ID: This is the ID that Sagitec's design documentation tool uses to refer to the decision table.
  • Access Specifier: Specifies the level of accessibility of the decision table.
  • Static: If checked, the decision table will be available to call from anywhere. Otherwise, you will have to call it from an instance of its object. In a decision table, the attributes of the entity can be directly used if it is not static.
  • Trace: Making a decision table traceable means you can view the path and result every time the code executes that decision table.
  • Match all condition: If checked, this changes the way the application executes the rule. By default, if it finds a match in a row condition, it skips the rest of the rows and moves on to the next column condition. With Match all condition, it continues to check every row even if it finds a match. This checks for overlapping data.
  • Throw Error: Every time the code executes that rule, it will display an error from the framework (not a configured error from an error table).
  • Cache Result: If Static is checked, this displays. When checked, the system stores the result of the decision table's execution in the cache. The next time it runs the decision table, it retrieves the result from the cache rather than re-execute the decision table.
  • Description: Optionally, you can enter a short description for your decision table.
The Creation Type options are:

Without Excel: You are using parameters and entity attributes to create a decision table.
With Excel: You are importing an Excel file as a decision table.
Query: You are importing query results as a decision table.

The Access Specifier options are:

Public: Any entity can access this decision table.
Private: Only this entity can access this decision table.
Protected: Only this entity and any child entity can access this decision table.


When you click Finish, Xelence creates the new decision table.



Step 4. Open the Parameters panel, then add the parameters.

The parameters (variables) you define here will be used later to provide the columns. This example creates two parameters.



Step 5. Enter the parameter details, then click OK.

The properties are:

  • Data Type: This is the type of data the decision table either takes in or returns (string, int, etc.).
  • ID: This is the variable name. It's the sting you'll use as the column name later.
  • Direction: Either in or out. An expression variable is an in variable. A value variable is an out variable.
  • Description: You can optionally enter a description of the variable.
  • Data Format: You can define the format for data like dates, currency, etc.




Step 6. Enter Descriptions for the column headers.

Each cell in a decision table consists of a Description and expression or value. Enter detailed Descriptions so others can understand your decision table.


Step 7. Enter the column header variables.

Xelence creates a decision table with four cells. The top cells are headers that define the input and result values of the rows underneath. The left column is the input and the right column is the result based on that input. You can add as many input columns and result columns as you want (this example keeps it to two). Enter a string to define the input (Expression) and a string to define the result (Value). These strings match the variables you created earlier.



Step 8. Add desired conditions.

Each row in this decision table is a condition. Xelence created the table with only one condition, but this decision table is going to have eight, so this example adds another seven.

To add a condition, right-click the left cell in a condition and select Add Condition.



Step 9. Enter descriptions and expressions for the conditions.

For each cell, enter the description of its expression or value, then enter the expression or value itself. An expression defines the input that returns the associated result, and the value defines the result that returns, given the associated input.

There are two options for viewing your decision table, The example below demonstrates Developer View. Descriptions and expressions/values both display. You can also view a decision table in Analyst View, where only Descriptions display. It is possible for one person to create a decision table in Analyst View with only Descriptions, and for another person to finish the table later with the actual logic.



Step 10. Save the decision table.

The decision table is configured. You may now call it elsewhere in your project, based on its accessibility and static settings.


What are the improvements over S3 Version 6?

This is an identical process.


Related Articles

Test the Decision Table

Add a Variable to an Existing Decision Table and Test the Rule

Add a New-Date Specific Version to the Decision Table and Test the New Version


This post is part of the Rules topic. Click here to open the Rules Overview.

#Xelence
#Rules

0 comments
166 views