Validators

A script validator is a powered-up version of a standard Jira validator. Instead of using one of the basic validators that you find in Jira, you can run a script to validate your issue. If the script returns false, it does not transition until all errors are resolved, for example, when all required fields are complete. Validators allow administrators to determine what error message is displayed to the user.

Remember, a validator checks to see if the user can transition an issue. They don't prevent the next transition button from appearing. A script condition gives you more options to control the workflow.

ScriptRunner for Jira Cloud provides workflow validators using the Jira Expression Framework. It is not possible to use the REST API.

There are several ways to enhance your workflow using script validators, as shown in the examples, including:

  • Require a Fix Version if the resolution value is set to Fixed.

  • Require a comment when the resolution is Won't Fix.

  • Ensure all at least one sub-task is In Progress if the resolution of the parent issue changes to In Progress.

Navigate to Context Variables to see the variables provided by this framework that can be used to create expressions. Click the variables to view the properties that can be called.

Limitations

Some restrictions apply to the evaluation of expressions using the Jira Expression Framework. An expression can execute up to 10 expensive operations. Expensive operations are those that load additional data, such as entity properties, comments, or custom fields. 

Atlassian provides information on Jira Expressions Types and lists the properties and functions which trigger expensive operations so users can determine the operation complexity of expressions being evaluated. 

You can execute expressions using the Evaluate Jira expression REST API operation and use the meta.complexity expand parameter to see the runtime complexity and number of expensive operations triggered.

Add Validator

For help navigating to ScriptRunner workflow functions, follow the steps in the Example Workflow Extension

  1. Select the transition you wish to add the validator to.

  2. Click Validators→Add Validator.

  3. Select the ScriptRunner Script option then Add.

  4. Enter the Name of ScriptRunner Script Validator.

  5. In the ScriptRunner Script Validator field, enter the script validator expression. This script validator must be written as a Jira expression.

  6. Type an error message to show when the validator fails in Message to Show when Validation Fails.

Edit Validator

  1. Navigate to ScriptRunner → Workflows. All existing workflows are displayed as default.
  2. Select Validator from the Type drop down list. You will now see a refined list displayed.
  3. Click the Actions ellipsis for your preferred workflow and select Edit.
  4. Edit the validator fields and click Save.
On this page