Heads up! ScriptRunner documentation is moving to docs.adaptavist.com. Adaptavist will keep this site up for a bit, but no future updates to documentation will be published here. ScriptRunner 6.20.0 will be the last release to link to scriptrunner.adaptavist.com for in-app help.

Making a field required for a given project for a particular transition, using the workflow validator

You can use Jira Suite Utilities to make fields required on certain transitions, the problem is they are not shown as required until you submit. Create a new behaviour or edit an existing one. Click the Enable link next to "Use Validator Plugin". Ensure this behaviour is associated with a project.

When going through a transition that requires a field, these should be shown as required before you submit. In this example I have added Fields Required validator on the Resolve action.

fixversion reqd

Set one field based on another field with information provided by the server

In this next contrived example, we will set a read-only field with the component lead’s user name. You need a server validator on the Component field to get the component lead, and you will make another field read-only.

Create a User-type field, in this example I’ve called it UserPicker (if you try this example you must call the field the same thing, unless you modify the code). The behaviour should look like this:

set comp lead bhv

Of course the path to your script will probably be different. This script in this case is:

import com.atlassian.jira.bc.project.component.ProjectComponent

def formComponent = getFieldById(fieldChanged)
def formUserField = getFieldByName("UserPicker")

def components = formComponent.getValue() as List<ProjectComponent>

// if any components have been set, set the user field to the component lead of the first component
// otherwise unset it
if (components) {
} else {

This illustrates an alternative way of changing the behaviours using the UI rather than code, to make the user field is read-only. In general it’s preferable, and more portable and flexible, to set behaviours using code rather than the UI.

On selecting a component the field value should change:

set comp lead

If you remove all components it will be cleared.

Have questions? Visit the Atlassian Community to connect, share, and learn with other Atlassian users and experts, including Adaptavist staff.

Ask a question about ScriptRunner for JIRA, Bitbucket Server, or Confluence.

Want to learn more? Check out courses on Adaptavist Learn, an online platform to onboard and train new users for Atlassian solutions.