...
Each of these has examples of SIL code.
Info | ||
---|---|---|
| ||
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 | ||
---|---|---|
| ||
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 | ||
---|---|---|
| ||
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 | ||
---|---|---|
| ||
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 | ||
---|---|---|
| ||
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 | ||
---|---|---|
| ||
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 | ||
---|---|---|
| ||
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 | ||
---|---|---|
| ||
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:
...
Code Block | ||
---|---|---|
| ||
customfield_10000 = formatNumber(123456789 ,"###,###.###"); |
Add a comment to all blocked issues when this issue is transitioned
Info | ||
---|---|---|
| ||
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
Setting current user as a watcher for the current issue:
Code Block | ||
---|---|---|
| ||
Info | ||
| ||
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 | ||
---|---|---|
| ||
watchers = addElement(watchers, currentUser()); |
...
Code Block | ||
---|---|---|
| ||
watchers = deleteElement(watchers, currentUser()); |
Create issue link
Info | ||
---|---|---|
| ||
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 | ||
---|---|---|
| ||
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 | ||
---|---|---|
| ||
string[] issues = arraysConcat(subtasks(key), linkedIssues(key, "Duplicates")); for(string issue in issues) { autotransition("Close Issue", issue); } |
Set/Read user property
Info | ||
---|---|---|
|
...
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 | ||
---|---|---|
| ||
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 | ||
---|---|---|
| ||
if(priority == "Critical") { autotransition("Ask For Approval", key); } |
Auto-transition parent when all sub-tasks are resolved
Info | ||
---|---|---|
| ||
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 | ||
---|---|---|
| ||
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 | ||
---|---|---|
| ||
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 | ||
---|---|---|
| ||
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 | ||
---|---|---|
| ||
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); } } |