Versions Compared

Key

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

Table of Contents

Table of Contents
excludeSee also
Tip

Before using SIL Script Custom Field, see Simple Issue Language documentation for more information about SIL usage and capabilities.

Configuring the PCF - SIL Script custom field

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

    image-20240212-152332.png
  2. Click Edit SIL Script and the following screen appears with a General taband a Scripts tab.

    image-20240213-104536.png
    • General tab: Set the formatting of the value under “Value formatted as” option. It can either be “Script Template”, “Date” or “Date Time”, depending what your SIL script will return. You can set the field’s Refresh interval to “Always”, “Never” or “Specify interval”. The refresh interval does not refresh on the field on that interval.
      Instead, when the value is needed and if the interval passed, the field is recalculated.

      For example, if the Refresh interval is set to Always, and, for example, the field’s value reflects the current minute, when searching issues by the field's value you have to search for the last value that was viewed in a non-editable place (like, the View issue screen). If you search for the current minute, the value won’t be present in the search results.

    • Scripts tab: Here you have to set the field’s SIL script (the script that computes the value to be displayed), and optionally, the template (see SIL Template Language).

      image-20240213-105652.png

  3. Click Save, and the . The script is associated with the current custom field.

    image-20240213-110138.png

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

    image-20240213-110215.pngimage-20240213-110257.png
Warning
Warning

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

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

  • This field only appears in non-editable places, like on the View screen of an issue or as a column in a JQL search.

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";

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'");

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);

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;

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-20240213-110845.png
  4. If you are about to add a new SIL Script custom field, you can choose the Search Template at the custom field creation step.

  5. After changing the Search Templates for all the custom field that you want, perform a re-index in Jira for the search to work fine.

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

image-20240213-111417.png

For more details on searching issues in Jira, see the Jira Searching for Issues tutorial.

See More

Child pages (Children Display)
pagePower Custom Fields User Guide