PCF - SIL Script Custom Field

PCF - SIL Script Custom Field

Configure the PCF - SIL Script Custom Field

The PCF - SIL Script Custom Field is a custom field type that lets you display values calculated by a SIL script. The script can compute values using issue fields, project data, and other Jira system information.

Prerequisites:

  • Ensure you understand the basics of Simple Issue Language (SIL) and its capabilities.

  • You have Jira Administrator role and permissions.

  • You have already created a Power custom field of the PCF - SIL Script Custom Field type.

  1. Locate your PCF - SIL Script Custom Field on the Custom fields page and click Configure contexts. The configuration section will look like the one illustrated below:

    PCF - SIL Script custom field configuration links
  2. Click Edit SIL Script. This opens the configuration tabs for the custom field.

PCF - SIL Script custom field configuration page - General tab
  1. On the General tab, set the following:

Setting

Options

Setting

Options

Choose display format from the Value formatted as drop-down list.

  • Script Template: Formats the output using a custom template

  • Date: Displays the output as a date

  • Date Time: Displays the output as a date with time

Select a Refresh interval

  • Always: Recalculates whenever the value is needed

  • Never: Uses the initially calculated value

  • Specify interval: Recalculates after a set time period

Important note on refresh behavior:

The field recalculates only when its value is needed, and the interval has passed, not automatically at each interval. For example, with "Always" refresh, when searching for issues by a field that shows the current minute, you must search for the last displayed value rather than the current minute.

  1. On the Scripts tab, set the following:

    1. Enter your SIL script to compute the field's value. This script determines how the field's value will be calculated.

    2. (Optional) Configure a template (see SIL Template Language). Use this to format how the calculated value is displayed.

  2. Click Save. The script is now associated with the current custom field.

    Edit SIL Script link for configured PCF - SIL Script Custom Field

     


How the field displays

Here's how the custom field appears in your Jira instance. The value returned by the script will be displayed as the field's value.

Important notes on script limitations:

  • The script is readonly; changes to issue values won't be saved.

  • While the field appears in both View and Edit screens, it remains read-only.

  • Some functions may have side effects.

Display example 1

The screenshots below illustrate the PCF - SIL Script Custom Field displayed on edit issue and view issue screens in Jira.

PCF - SIL Script Custom Field on edit issue screen
PCF - SIL Script Custom Field on view issue screen

Display example 2

This example illustrates how the template script modifies how the value of the custom field is displayed.

Script

Script configuration screen

Field displayed on View screen

Script

Script configuration screen

Field displayed on View screen

If you enter this script in the SILSCRIPT file:

return currentDate();

 

Scripts tab on PCF-SIL Script custom field configuration page with selected SILSCRIPT.

This is how the field value displays:

PCF-SIL Script Custom Field on view issue screen without template.

If you add this script in the TEMPLATE file:

<html> <head> Current date is: </head> <body> <p style="color:red;">$currentDate()$</p> </body> </html>

 

Scripts tab on PCF-SIL Script custom field configuration page with selected TEMPLATE.

This is how the field value displays

PCF-SIL Script Custom Field on view issue screen with template.

 


Examples

Example

Sample script

Sample display output

Example

Sample script

Sample display output

Display Issue Age

This script calculates and displays how long an issue has existed.

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

“This issue is 10w 1d 1h 5m 26s old”

Display the number of substacks for a ticker

This script counts and displays how many subtasks are associated with an issue.

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

 

“This issue has 5 subtasks”

Display average age of subtasks

This script calculates and displays the average age of all subtasks for an issue.

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

 

“Average age of subtasks is 4d 12h 45m”

Display results from database

This script retrieves city names from a database based on a specific region.

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

 

Returns a list of cities from the Bucharest region, for example: "Sector 1, Sector 2, Sector 3"

Display duration in current status

This script calculates and displays how long an issue has been in its current status. If there's no status history, it shows the total issue age.

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

 

“Current issue has been In Progress for 2d 4h 30m”

Display unique status changes count

This script counts how many different statuses an issue has gone through in its lifecycle.

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

 

“3” (indicating the issue has been in three different statuses)

Display all historical assignees

This script lists all users who have ever been assigned to an issue, including the current assignee.

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;

 

“John Smith, Jane Doe, Mark Wilson" (a list of all users who have been assigned to the issue)


Configure search settings for your PCF - SIL Script custom field

  1. Locate your PCF - SIL Script Custom Field on the Custom fields page and click Edit details.

  2. Select a Search Template compatible with your field's return value type.

    Search Template drop-down list on the Edit Custom Field Details page.
  3. Click Update.

After the update, reindex your Jira instance to ensure search functionality works correctly.

  1. Test the search functionality.

Search box with search results displayed in Jira.

To learn more about the search functionality, see the Jira Searching for Issues tutorial.

 

Need support? Create a request with our support team.

Copyright © 2005 - 2025 Appfire | All rights reserved.