Skip to end of banner
Go to start of banner

Creating and using decision tables with SIL

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 22 Next »

Creating and using decision tables with SIL

 

Required plugins

You will need the following JIRA plugins:
  1. JJUPIN

Level:  INTERMEDIATE

Problem

Depending on one or more criteria one needs to decide on which way to go

Usages

  • assigning an issue to a predefined user
  • setting some (custom) fields
  • any other behavior

Considering we have a custom field named Department with the following values:
Production
Sales
HR

And we would like to assign an issue to the Department manager at a certain stage.

Solution

Create the decision table


1. Create a table with the department managers (for example named dept_managers):

Department

Manager

Production

john

Sales

mark

HR

marie

Note

We use the user-names and not the manager's full name so we can assign them easily

Writing the code

2. Write the SIL code to assign the manager

AssignManager.sil
string sqlSelect;
string[] sqlResult;
string user;

sqlSelect = "select manager from dept_managers where department = '" + Department + "'";
sqlResult = sql("myDB", sqlSelect);

user = getElement(sqlResult, 0);

if(isNotNull(user))
  assignee= user;

What the code does is the following:

  • it constructs a dynamic SQL named sqlSelect
  • it runs the SQL and saves the result in the sqlResult variable which is defined as a string array
  • grabs the user from the first location of the result (index 0)
  • if found, assigns the issue to the user

So, in our example, if the Department custom field is set for example to HR, the assignee will be set to marie.

  • No labels