Post-Function Templates

Post-functions are actions that occur after an issue is transitioned. Post-functions represent one of the largest categories of use cases for automation.

The templates will create the post-function by adding a new post-function script to an existing workflow transition within Jira.

Setting up the Post-Function Templates

Because the post-function script needs to live in an existing workflow transition the first two steps to creating a post-function script template will be selecting the workflow and transition for where the post-function should be place.

Sample post-function template configuration

If you are unsure which workflow to use an easy way to check is through the “view workflow” link that will present on any issue in Jira. Make sure you use an issue for the project and issue type you wish to add the post-function to.

This “view workflow” link may not always be present due to permission settings. You may need to look in the project settings in order to determine which workflow you should select.

NOTE: Because the post-function script occurs at the end of the transition, transition screens are not relevant to the post-function script.

Testing the Script

Testing the script is as simple as completing the transition and checking if the post-function action occurred. For example, if the script was designed to create subtasks after the transition, check to see if the subtasks were created. If not, see this section about troubleshooting scripts.

Templates

Assign issue

Assign an issue to a selected user after the issue is transitioned.

Inputs

Name

Required

Description

User

YES

The specific user for which the issue will be assigned.

Description

NO

The description text will be added to a comment at the head of the script so other users can be informed of the purpose of the script.

Script

assignee = "jmuse";

Add Comment

Add a comment to the current issue after the issue has been transitioned to a certain status.

Inputs

Name

Required

Description

User

NO

If a default user is specified, this user will be recorded as the user who created the comment. If no user is specified then the user who transitioned the issue will be recorded as the user who created the comment.

Comment

YES

The text that should be added to the issue as a comment.

Description

NO

The description text will be added to a comment at the head of the script so other users can be informed of the purpose of the script.

Script

string selectedUser = ""; string comment = "Hello World"; if(selectedUser == ""){ addComment(key, currentUser(), comment); }else{ addComment(key, selectedUser, comment); }

Add Watcher

A SIL post-function that will add a watcher on the current issue after the issue is transitioned.

Inputs

Name

Required

Description

User

YES

The specific user who should be added as a watcher for the issue.

Description

NO

The description text will be added to a comment at the head of the script so other users can be informed of the purpose of the script.

Script

watchers = watchers + "jmuse";

Send an Email

A SIL post-function that will send a custom email to the desired address, project role, or user group after the issue is transitioned.

Inputs

Name

Required

Description

From

NO

The address that the email should be sent from.

To

YES

The recipients email address.

CC

NO

List of CC email addresses.

Subject

YES

The subject of the email.

Body

YES

The text body of the email.

Description

NO

The description text will be added to a comment at the head of the script so other users can be informed of the purpose of the script.

Script

NOTE: In order for this post-function to successfully send an email Power Scripts must first be configured for sending emails. The default setting will not send out any emails.

NOTE: If using the “From” field the mail account specified in the email configuration must be set up to be allowed to send from multiple addresses. An example of this is when an assistant can send an email as their boss from their own email account. Otherwise, the email account specified in the email configuration will be who the email is sent from.

NOTE: HTML tags can be used within the body of the email.


Clone Issue

A SIL post-function that will clone a Jira issue after the issue is transitioned.

Inputs

Name

Required

Description

Link Type

NO

If specified, this link type will be used to link the original issue to its clone.

Parent Key

NO

If specified, the cloned issue will be added as a subtask to the parent issue. The original issue must be of subtask type in order for this to occur.

Description

NO

The description text will be added to a comment at the head of the script so other users can be informed of the purpose of the script.

Script

NOTE: The name of a link type is not the same as its inward and outward description. For example, the link type of “Cloners” has an inward description of “is cloned by” and an outward description of “clones”. Understand that the values you see when linking issues are the descriptions and not the name of the link type. To view a list of link types in your system see the Issue Linking page in the Jira admin.


Copy Field from Parent

A SIL post-function that will copy a custom field from parent after the issue is transitioned.

Inputs

Name

Required

Description

Custom field

YES

The specific custom field that should be copied from the parent.

Description

NO

The description text will be added to a comment at the head of the script so other users can be informed of the purpose of the script.

Script


Copy Field to Subtasks

A SIL post-function that will copy a custom field's value from a task to it subtasks after the issue is transitioned.

Inputs

Name

Required

Description

Custom field

YES

The specific custom field that should be copied to the child subtasks.

Description

NO

The description text will be added to a comment at the head of the script so other users can be informed of the purpose of the script.

Script


Create Subtask

A SIL post-function that will create a subtask after the issue is transitioned.

Inputs

Name

Required

Description

Summary

YES

Summary of the subtask being created.

Description

NO

The description text will be added to a comment at the head of the script so other users can be informed of the purpose of the script.

Script


A SIL post-function that will link another issue to the current one after the issue is transitioned.

Inputs

Name

Required

Description

Issue Key

YES

Issue key for which the issue should be linked to.

Link Type

YES

Link type that should be used when linking the issues.

Description

NO

The description text will be added to a comment at the head of the script so other users can be informed of the purpose of the script.

Script


Set Field Value

Set a field to a value after the issue is transitioned.

Inputs

Name

Required

Description

Custom Field

YES

The custom field that should be set by the script.

Field Value

NO

The value that should be given to the custom field.

Description

NO

The description text will be added to a comment at the head of the script so other users can be informed of the purpose of the script.

Script

Transition Parent

A SIL post function that will transition the parent to a new status.

Inputs

Name

Required

Description

Transition status

YES

The new status for the parent issue to be transitioned to.

Description

NO

The description text will be added to a comment at the head of the script so other users can be informed of the purpose of the script.

Script