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 enable administrators to specify the error message 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 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 Example Conditions and Validators, including:

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

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

  • Ensure that 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.

Add Validator

  1. Navigate to the Workflows menu from within Jira's settings. You will see Active and Inactive workflows displayed.
  2. Click Edit from the Actions ellipsis for your chosen workflow, and the workflow opens. You can choose to view the workflow as a diagram or text; we will use the former for this example.
  3. Select a transition from within the workflow diagram. A list of associated workflow functions, including Conditions, Validators, Post Functions, Triggers, and Properties, is displayed for the selected transition.
  4. Click Validators > Add Validator.
  5. Select the ScriptRunner Validator option, then Add.
    A screenshot of the ScriptRunner validator selected and the Add button highlighted.

  6. Enter the Name of ScriptRunner Script Validator.

  7. Enter the script validator expression in the ScriptRunner Script Validator field. This script validator must be written as a Jira expression.

  8. 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 the 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