Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Install Scriptrunner by Adaptavist.

  2. Access the workflow editor.

  3. Choose the relevant transition and click on Validators, then Add Validator.

  4. Opt for the ScriptrunnerScript option with the description "Add a ScriptRunner Script Validator that evaluates a Jira Expression to determine whether data input to the transition is valid".

  5. Assign a name to the validator.

  6. Compose a custom message that users will see when they attempt to transition the table, but the table has no values and does not fulfil the Jira Expression requirement.

  7. The Script Validator field is where you can input the Jira Expression or validation condition.

Jira expression:

Code Block
issue.properties['stjc-field-22'] != null

...

where

22 is the table Table ID.

Column value validation

Example 1. Validation is passed if all column has values in every row of the table

Code Block
(issue.properties['stjc-field-22']?.values ? issue.properties['stjc-field-22']?.values?.filter(v => !v.get("2974")).length : 1) == 0

where

22 is the Table ID;

2974 is a Table column ID.

Example 2. In the example below, the Jira Expression validates if the transition’s sum of field values is 50 or more.

Code Block
(issue.properties['stjc-field-

...

22']?.values ? issue.properties['stjc-field-22']?.values?.reduce((a, b) => a + Number(b.get("2974")) ,0) : 0 ) >= 50

...

22 is the Table ID;

...

Example 3. Validation is passed is there is a column value at least in one row in the table

Code Block
(issue.properties['stjc-field-22']?.values ? issue.properties['stjc-field-22']?.values?.filter(v => v.get("2974")).length : 0) > 0