Fast-track Transition an Issue

This post-function will automatically transition an issue if the provided condition holds true. Let’s take a contrived example again. Imagine that all new Critical priority issues should go to the CCB for approval when the issue is created.

To realize this we add this post-function on the Create Issue transition.

It’s not obvious how to get to the properties of the Create Issue transition. Click the first step, then the action will be available in the box at top right.

Place this as the last post-function, or at least after the Fire Event function. If you don’t do this, it won’t work.

So, if the issue has priority == Critical the issue will automatically have the "Requires CCB Approval" action applied on it.

When choosing a workflow action, note that you may see multiple actions of the same name. The key thing is the ID. It must be a valid transition from the target state of this action. You can get the ID by mousing over the links in the transition.

Note that if you need to provide additional parameters for doing a transition, for instance when Resolving an issue, you can enter code in the Additional Code field. The following sets the resolution and assigns to a user:

import com.atlassian.jira.component.ComponentAccessor def constantsManager = ComponentAccessor.getConstantsManager() def resolution = constantsManager.resolutions.findByName("Done") issueInputParameters.setResolutionId( issueInputParameters.setAssigneeId("admin")

We use IssueService to conduct the transition, which makes an effort to behave in the same way as the user interface.

If the field you are updating does not appear on the screen for the transition, or there is no screen, you should add the following line:

Using IssueService directly, you can only update fields on the issue if there is a screen for that transition, and you can only update those fields that appear on the screen. However, we allow you to update the issue even if there is no screen

You can always add a comment using issueInputParameters.setComment('Some comment'). Do not also ignore the screen check if you do this, there is a bug that will cause the comment to be added twice.

Transition Options

These options allow you to skip validators, conditions and permissions on transition. For example this is useful when you want to force the transition to happen as a user that does not have the correct permissions, or you want to make use of the standard condition that hides the transition from users.

You can use this script multiple times on a transition, eg the Create Issue transition, to effect different default start statuses for an issue, depending on some value or other.