The Adaptavist Group LogoDocumentation

Workflow Functions Tutorial

Note: For a visual demonstration of workflow functions, see our Workflow Functions training video.

ScriptRunner for Jira Server provides built-in and custom workflow functions. These workflow functions include built-in and custom validators, conditions, and post functions. ScriptRunner workflow functions allow you to do a lot more with your Jira workflows and further enhance your automation.

Explore the following sections within this page to learn more:

Jira workflow functions

As a reminder, a workflow is the series of steps through which a piece of work passes from conception to completion. In Jira, workflows are made up of two main parts; statuses and transitions. Statuses indicate that someone is working (or not working) on the issue, while transitions link statuses together. You can control several aspects of a transition's behavior in Jira. For instance, you can have:

  • Conditions that check to make sure the user should be able to perform a transition.
  • Validators which ensure that all needed changes have been made or that the changes that were made were valid.
  • Post Functions that program automated actions after the transition is performed.

These workflow functions enable a level of automation in your projects. This automation keeps your teams focused on their work, while Jira takes care of the repetitive tasks your team doesn't need to focus on. However, you may find that Jira's basic workflow functions don't always do as much as you would like them to do—and that's where ScriptRunner workflow functions come in!

Note: Jira Workflows

For more information on Jira Workflows, we recommend you familiarise yourself with the Atlassian documentation on workflows.

ScriptRunner workflow functions

For each of the Jira workflow functions, ScriptRunner for Jira provides built-in and custom workflow functions so that you have workflows that suit your exact needs. There are three main types of ScriptRunner workflow functions:

For example, you can use the All sub-tasks must be resolved built-in script condition to ensure that all sub-tasks have been resolved before the transition is allowed. See below for a full list of ScriptRunner workflow functions.

Available ScriptRunner workflow conditions

The following ScriptRunner conditions are available when you add a condition to a workflow transition:

ScriptRunner conditionsDescription
Simple scripted conditionRuns a simple embedded script to find out whether to show the action or not.
Custom script conditionRun your own Groovy script from a file or enter it into Jira.
All sub-tasks must be resolvedDo not allow the action unless all sub-tasks have a resolution set. You can choose any resolution: a named one or the same as the parent task.
Field(s) required conditionAllow the transition if required fields are completed.
Group(s) conditionAllow the transition if the current user is, or is not, a member of the specified group(s).
JQL query matches conditionAllow the transition if the current issue matches the provided JQL query.
Linked issues conditionControl the transition based on the status or resolution of linked issues or sub-tasks.
Checks the issue has been in a status previouslyRequire that this issue has been in the specified status either previously, or immediately prior.
Project role(s) conditionAllow the transition if the current user is, or is not, a member of the specified project role(s).
Regular expression conditionCheck a system or custom field value that matches a regular expression.
User(s) conditionAllow the transition if the current user is, or is not, included in the list of users.
User in field(s) conditionAllow the transition if the current user is in the User or Group field.

Available ScriptRunner workflow validators

The following ScriptRunner validators are available when you add a validator to a workflow transition:

ScriptRunner validatorsDescription
Custom script validatorRun your own Groovy script from a file or enter it into Jira.
Simple scripted validatorRun a simple embedded script to find out whether to allow the transition or not.
Field(s) changed validatorEnforce that one or more fields are changed as part of the transition.
Require a comment on transitionEnforce that a comment is provided on transition.
Field(s) required validatorAllow the transition if Required fields are completed.
Regular expression validatorMake sure a system or custom field value matches a regular expression.
User in field(s) validatorAllow the transition if the current user is in the User or Group field.

Available ScriptRunner workflow post functions

The following ScriptRunner post functions are available when you add a post function to a workflow transition:

ScriptRunner post functionsDescription
Custom script post-functionRun your own Groovy script from a file or entered into Jira.
Add/remove from sprintAdd/remove the issue to/from a sprint on transition.
Adds the current user as a watcherAdds the user performing the action as a watcher, if condition applies.
Archive this issueArchive the current issue, which can help improve performance.
Assign to last role memberAssign this issue to the last user from the specified role who this issue was assigned to previously.
Assign to first member of roleAssign to the first member of the specified role.
Clear field(s)Clear selected fields.
Clones an issue, and linksClones this issue to another issue, optionally another project and issue type, and creates a link.
Add a comment to this issueAdds a templated comment to the current issue, as the user making the transition.
Copy field valuesCopy field values from one field to another.
Create a sub-taskCreate a sub-task. Will optionally reopen a matching sub-task.
Fast-track transition an issueIf the condition is met, automatically transition this issue to another status.
Fires an event when condition is trueFires an event that can be picked up by a notification scheme, in order to send mail only under certain conditions, for example, Priority is Blocker.
Post a message to SlackAllows you to define a customizable message to send to a Slack channel.
Transition parent when all sub-tasks are resolvedTransition the parent issue through the provided action when all sub-tasks are resolved.
Send a custom emailSend an email based on the provided template if conditions are met.
Set issue security level depending on provided conditionSets the security level for an issue if the provided condition evaluates to true.
Adds a comment to linked issues when this issue is transitionedUseful for alerting participants of other issues that a blocker is resolved, etc. This function should be put on the Resolve transition (or similar).

Access ScriptRunner workflow functions

You can access ScriptRunner workflow functions as follows:

  1. Go to Administration → Issues → Workflows.
  2. Select Edit on the workflow you want to add a condition to.
  3. Select the transition you wish to add a the workflow function to.
  4. Under Options, select then workflow function or your choice.
Tip: For detailed instructions on how to navigate to ScriptRunner workflow functions, see our documentation.

Your next steps depend on if you edit a workflow condition, validator, or post function. We have provided you with examples for each in the section below.

Note: Remember to publish!

Remember when editing a workflow, changes result in a draft that you must publish before you see them take effect in your workflow. Since you can use both built-in workflow functions and scripted workflow functions that you customize, there is a lot of flexibility to what you can do with ScriptRunner.

Search documentation

Start typing to search the docs.