Versions Compared

Key

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

...

Each of these has examples of SIL code.

You will need the following Jira app:
Info
titleRequired plugins
apps

Power

Scripts

Scripts™ for Jira(server)

Level: BASIC

Making a HTTP request to an external system

...

This post function can be used on the Create transition to set a different issue security level depending on whether the issue is being created by a developer or by any other user.

Transition parent issue

Info
titleAvailability

This feature is available for the Jira server deployment option only. We plan to add it to the Cloud version in the near future.

A SIL post function that triggers a named transition on the parent issue of the current sub-task:

...

When executing the transition on sub-task, the "Start Progress" transition will be triggered on the parent issue, if this transition is valid for the current status of the issue.

Sending a custom email

...

Info
titleAvailability

This feature is available for the Jira server deployment option only. We plan to add it to the Cloud version in the near future.

A SIL post function that sends a custom email. For example, the reporter of the issue wants to be notified when the assignee resolves the issue. You can do this with the following code:

...

Code Block
titleSIL Code
description = "Current issue of type " + issueType + " was created on " + created + " by " + userFullName(reporter) + " in project " + project 
		+ " with the following summary: '" + summary + "'.\n"
		+ "It affects versions " + (string)affectedVersions + " and is expected to be resolved on " + dueDate + ".";

 


A customized text is added as a comment at the moment of issue closing:

Code Block
titleSIL Code
string USER = currentUser();
string COMMENT = "Closed on " + updated + " by " + userFullName(USER) + " with fixed versions " + (string)fixVersions + ".";
addComment(key, USER, COMMENT);

 


Copy issue labels to a custom field:

...

Code Block
titleSIL Code
string[] subtasks = subtasks(key);
for(string subtask in subtasks) {
    components = arraysConcat(components, %subtask%.components);
}

 


Removing reporters of linked issues from a Multi User field called Team:

Code Block
titleSIL Code
string[] linkedIssues = linkedIssues(key);
for(string issue in linkedIssues) {
    Team = deleteElement(Team, %issue%.reporter);
}

...


Combining the values of several Multi User picker fields:

...

where Number is the name of a numeric custom field and MultiSelectList is the name of the Multi Select custom field.

 


Updating Due Date with respect to current date (eg adding 2 days):

Code Block
titleSIL Code
dueDate = currentDate() + "2d";

 


Setting total time spent by adding current date-time - date-time of last update:

...

In the above example we use a string in the issue description  to alter the issue priority upon issue creation. The description must contain a string of form REPORTEDPRIORITY=1 for fetching the priority id.

We make use of the SIL SIL™ routines matches, indexOf, length and substring. More useful string routines can be found in the String routines section.

 


Setting field based on reporter's email:

...

The Defect value changes during the creation transition to Development if the reporter's email address matches a '@gmail.com' email address.

 


Setting watchers depending on the value of a custom field:

...

In the above example, if in the multi user picker Customers custom field there are selected users which contain the value "BT" in their full name, these users are set as watchers upon creation.

 


Setting a custom field (User Picker) based on the value of another custom field (Text Field):

...

Set due date to current date at issue creation

A SIL SIL™ post function that sets the due date to current date at issue creation, if no value was specifically set for the due date:

...

Assign an issue to a reporter or a user depending on the project key

A SIL SIL™ post function for assigning an issue to user tester if project is TST, or assign it to the issue reporter otherwise:

...

Turn issue unassigned when assigned to project leader

A SIL SIL™ post function that turns an issue unassigned if it is assigned to the project leader:

...

Setting a text custom field with the formatted value of a number: 


Code Block
titleSIL Code
customfield_10000 = formatNumber(123456789 ,"###,###.###");
The value will be displayed as: "123,456.789". For more details check out the formatNumber routine page.

Add a comment to all blocked issues when this issue is transitioned

...

Info
titleAvailability

This feature is available for the Jira server deployment option only. We plan to add it to the Cloud version in the near future.

Adding a comment on behalf of the current user, to all blocked issues by the current issue transitioned:

...

Automatically adding or removing watchers from a workflow transition

Info
titleAvailability

This feature is available for the Jira server deployment option only. We plan to add it to the Cloud version in the near future.

Setting current user as a watcher for the current issue:

...

Code Block
titleSIL Code
watchers = deleteElement(watchers, currentUser());
Info
titleAvailability

This feature is available for the Jira server deployment option only. We plan to add it to the Cloud version in the near future.

A SIL post-function that links the current issue to another issue by the Relates issue link type:

...

Close sub-tasks and duplicated linked issues when current issue is closedissue is closed

Info
titleAvailability

This feature is available for the Jira server deployment option only. We plan to add it to the Cloud version in the near future.

A SIL post-function that closes all subtasks and duplicated issues for current issue when close issue transition is triggered:

Code Block
titleSIL Code
string[] issues = arraysConcat(subtasks(key), linkedIssues(key, "Duplicates"));
for(string issue in issues) {
    autotransition("Close Issue", issue);
}   

Set/Read user property

Info
titleAvailability

...

This feature is available for the Jira server deployment option only. We plan to add it to the Cloud version in the near future.

A SIL™ post-function that sets the "country" property for the current user and puts it into a text custom field with id customfield_10100:

...

Copy a cascading select custom field to a simple text custom field

A SIL SIL™ post-function that copies the string representation of a cascading select custom field value with name "Cascade" into a text custom field with id customfield_10100:

...

Fast-tracking (auto-transition) an issue through another action if a condition is trueis true

Info
titleAvailability

This feature is available for the Jira server deployment option only. We plan to add it to the Cloud version in the near future.

Using this you can effectively have multiple start states for a workflow, with the initial state depending on, for example priority, reporter, or whatever.

This SIL SIL™ post-function will automatically transition an issue if the provided condition holds true.

For example, if all new Critical priority issues should go to the Change Control Board for approval when the issue is created, this can be achieved with the following SIL SIL™ post-function:

Code Block
titleSIL Code
if(priority == "Critical") {
   autotransition("Ask For Approval", key);
}

Auto-transition parent when all sub-tasks are resolved

Info
titleAvailability

This feature is available for the Jira server deployment option only. We plan to add it to the Cloud version in the near future.

Put this SIL SIL™ post-function on the sub-task workflow on transitions where the workflow could be set, typically Resolve Issue. If all sibling sub-tasks are resolved this will transition the parent issue using the provided action (eg Resolve Issue):

...

Fire an event when condition is true

...

Info
titleAvailability

This feature is available for the Jira server deployment option only. We plan to add it to the Cloud version in the near future.

This SIL™ post-function can be used for conditional notification of only high priority issues for instance:

...

Clone an issue and link on transition

Info
titleAvailability

This feature is available for the Jira server deployment option only. We plan to add it to the Cloud version in the near future.

Yes, this is available in other places, but this method offers a lot of flexibility (at the expense of a fancy GUI).

...

If you want to override some of the field values rather than have them inherited from the source issue you can set their values after calling the cloneIssue routine.

The following SIL SIL™ post-function clones the current issue, creates a Duplicate link type between the two issues, and sets the summary for the cloned issue:

...

Create one or more sub-tasks on transition, and optionally reopen existing sub-tasks

...

Info
titleAvailability

This feature is available for the Jira server deployment option only. We plan to add it to the Cloud version in the near future.

This SIL™ post-function function can be used to create several sub-tasks.

...

Code Block
titleSIL Code
string[] SUMMARIES = {"First sub-task for approval", "Second sub-task for approval"};
string[] subtasks = subtasks(key);
    
for(string summ in SUMMARIES) {
    boolean exists = false;
    for(string subtask in subtasks) {
	if(%subtask%.summary == summ) {
	   autotransition("Reopen Issue", subtask);
           exists = true;
        }       
    }
    if(!exists) {
	createIssue(project, key, "Sub-task", summ);
    }
}

See also