Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Contents

Table of Contents
excludeSee also

Tip
titleRecommendation

Before using SIL Script Custom Field check out the , see Simple Issue Language documentation for a better grasp of SIL usage and capabilities.

How to configure

Go to the Administration page, choose Custom Fields link and add a SIL script custom field.

...

Configuring PCF - SIL Script custom field

  1. After you create the field,

...

  1. click the Configure link for this field. You will see the page like the following example:

    Image Modified

  2. Click

...

  1. the

...

  1. Edit SIL Script link to see the SIL editor.

...


  1. Image Added

...


  1. Click Save, and the script is associated

...

  1. with the current custom field.

...


  1. Image Added

  2. The value returned by the script will be the value of the custom field.

...


warning
Warning
title
Warning

The script is read-only. Please keep the following in mind:

  • You must avoid changing any issue values in the script. In fact, you
may
  • can change the issue variables
BUT
  • but they will not be changed (issue will not be saved). However, routines may have side effects.

...

  • This field only appears on the View screen of an issue or as a column in a JQL search

Thread Local Caching

Note

If you are not fully aware of what this implies, it is recommended we recommend that you leave the option off.

Because multiple calls to get the value of a SIL Script Custom Field custom field for a certain issue are inevitable, we implemented an option to generate the value only once per HTTP request. This can improve performance, but might have some side effects.
For exampleinstance, if the value is generated before some other values it depends on are modified, the result might not reflect the latest updates.

How to use it

...

Using PCF - SIL Script custom field

This is how the field displays the value returned by the script.

That's it.Image Modified

...


...

Examples

Seeing Issue Age

Code Block
interval age = currentDate() - created;
return "This issue is " + age + " old";

 

...

Showing the number of subtasks for a ticket

Code Block
number noSubtasks = size(subtasks(key)); 
return "This issue has " + noSubtasks + " subtasks";

 

Average Issue Age

Showing average age for issue subtasks

Code Block
date now = currentDate(); // just to make sure we use the same reference date
string [] subtasks = subtasks(key);
interval age;
for(string task in subtasks){
 age = age + (now - %task%.created);
}
return "Average age of subtasks is " + (age / size(subtasks));

 

...

Displaying results from the database

Code Block
//select the city from the specified region
return sql("TestSQL", "select city from cities c, district d, region r where c.iddistrict=d.id and d.idregion=r.id and r.region='Bucharest'");

 

Status Age

Seeing how long a ticket is in the particular status

Code Block
string field_name = "status";
string[] field_history = fieldHistory(key, field_name);
number n = arraySize(field_history);
date startDate; 
if (n > 0) {
 startDate = arrayGetElement(field_history, n - 2);
 return "Current issue has been " + status + " for " + (currentDate() - startDate);
}
return "Current issue has been " + status + " for " + (currentDate() - created);

 

...

Displaying statuses count for a ticket

Code Block
string[] statuses;
string[] statusHistory = fieldHistory(key, "status");
for(number i = 1; i < size(statusHistory); i = i + 2) {
 string statusStr = getElement(statusHistory, i);
 statuses = addElementIfNotExist(statuses, statusStr);
}
return size(statuses);

 

Issue Assignees

Seeing everyone who has ever been an Assignee for the ticket

Code Block
string[] assignees;
assignees = addElementIfNotExist(assignees, userFullName(assignee)); 
string[] assigneeHistory = fieldHistory(key, "assignee"); 
for(number i = 1; i < size(assigneeHistory); i = i + 2) {
 string assigneeName = userFullName(getElement(assigneeHistory, i));
 assignees = addElementIfNotExist(assignees, assigneeName); 
}
return assignees;

...

If you want a Sil Script Custom Field to be searchable you must select a Search Template for that custom field.

Image Removed

...

Making SIL Script custom fields searchable

  1. Log into your Jira as Admin.
  2. Go to Administration > Custom fields, and click Edit for the necessary SIL Script custom field.
  3. Select a Search Template for that custom field according to the value type returned by it.

    Image Added

  4. If you are about to add a new

...

  1. SIL Script custom field, you can choose the Search Template at the

...

 

...

  1. custom field creation step.
  2. After changing the Search Templates for all the custom field that you want, perform a re-index in

...

  1. Jira for the search to work fine.


After you set a searcher has been set for the Sil SIL Script custom field, you can perform a search for all issues containing the desired value for that custom field.

Image AddedImage Removed

See also

For a detailed explanation more details on searching issues in JIRA, you can check the Jira, see Searching for Issues tutorial from the JIRA Jira documentation.