Build-your-own (scripted) Validator

A workflow validator that is based on the result of a Jira expression.  

If the Jira expression returns false, a validation error message will be displayed. This can be used to test or compare issue fields, to test for linked issues, to check for open Sprints, among many others.

When you add this validator to a transition and attempt to trigger the transition, the extension checks the result of a logical test, comparing a field value to either another field value or to a set value. The logical test can be a Jira expression entered manually, or you can build an expression using the No Code option (see below). If the expression returns true the transition will trigger; if it returns false or any non-boolean value, a validation error message is displayed.

On the Service Management portal view of a request, the customer will not see the Error message when the validator fails. This is due to a known limitation (JSDCLOUD-5853) with Atlassian.

Configure the validator

  1. Follow the steps above to add a validator to a transition.

  2. From the list of validators, select Build-your-own (scripted) Validator (JMWE app).

  3. The Build-your-own (scripted) Validator page will open. Configure the validator as needed. See below for details on each of the configurations.

  4. Click Add.

Note that you will need to publish the workflow for the new validator to take effect.

The following configurations are available:

  • Description - Give the validator a description; this will be included in the list of validators for the transition and in the Workflow Extensions administration page.

  • No Code (Figure 1, right) - These fields will only display when Choose type is set to No Code. Select this option to create the validator without the need to write a Jira expression. Set each of the following options:

    • Field - Select the field to be tested.

    • Operator - Select the logical operation to use in the test; for example, Equals, Does not equal, is empty, Less than, or Greater than (among others).

    • Value to compare type - Select against what value the test will be evaluated:

      • Field - Compare the condition field against the value(s) of another field.

      • Text - Compare the condition field against a set value.

    • Value to compare - Either select a field from the pulldown menu, or enter a set value.

  • Jira Expression (Figure 2, right) - The Jira expression editor will only display when Choose type is set to Jira Expression. Enter the Jira expression for the logical test for the validator. If this test evaluates to false, the validator will fail and prevent the transition from executing.

  • Error message - The error message that will display if the validator fails.

  • Validator scope

    • Conditional validation - Check this box to configure the validator to only run in specific circumstances.

    • Condition - Only visible when Conditional validation, above, is checked. Enter a Jira expression; if the expression evaluates to true, the validator will run.

    • Skip validation when cloning an issue - Check this option to skip the validator when an issue is being cloned.

Computed Expressions

Computed Expression field showing the JavaScript result of configurations
Figure 3 - Computed Expression

If you use the No Code option to create your condition, the Computed Expression box (Figure 3, right) will populate with the equivalent Jira expression for your configurations. You will not be able to alter the script, but it is possible to test the script and to copy the script so it can be pasted elsewhere.

Click Test ( testscript.png ) to open a window where you can select an issue against which the script should be tested.

Click Copy ( copyscript.png ) to copy the script to your clipboard.

 

Build-your-own Validator No Code Configuration Screen
Figure 1 - Build-your-own Validator, No Code Option