...
Info | ||
---|---|---|
| ||
Power Scripts Scripts™ for Jira (server) Level: BASIC |
...
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 ,"###,###.###"); |
...
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 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:
...
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); } |
...
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):
...
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 SIL™ post-function can be used for conditional notification of only high priority issues for instance:
...
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:
...
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 SIL™ post-function function can be used to create several sub-tasks.
...