On this page
...
Info |
---|
This page describes how to block workflow transition if selected checklist items are not completed. As a result selected checklist items must be completed to move the issue to another status (e.g. Done or Resolved). At the same time, other checklist items can stay not completed and the transition will be still enabled. |
Info |
---|
If you want to enable transition only when all the items are completed then please follow the guide Block workflow transition if checklist is not complete. |
...
- Navigate to "Project settings > Workflows" or "Jira settings > Issues > Workflows".
- Edit the selected workflow (click "pen" icon or "Edit" link)
- Select Diagram view (1) and next select the transition (2) that you want to block, e.g. Done. After that press Validators link (3):
- Press "Add Validator" link:
- Select "Regular Expression Check" and press "Add" button:
Select "Checklist Text" field in the dropdown, and paste following value in "Regular expression" field, next press "Add" button:
Code Block (?ms).*^\*\s+\[(x|done|skipped)\]\s+first item.*
Below is an example of a regular expression that checks for two items:Code Block theme Confluence (?ms).*^\*\s+\[(x|done|skipped)\]\s+first item.*^\*\s+\[(x|done|skipped)\]\s+second item.*
- Confirm that validator is available on the list and press "Publish Draft" link
- Confirm that validator (blocking issue transition) works fine:
- Open issue in a project that uses modified workflow
- Add checklist items ("first item" and "second item")
Press transition button and observe error message displayed by Jira if "first item" is unchecked
Info |
---|
It is not possible to specify a custom error message for a blocked transition. The described solution relies on a built-in JIRA validator that comes with its own message. |
Info |
---|
The solution presented above is based on the checklist item text (please spot "first item" text in the regular expression). It means that for single item checklist items order is not important and the solution works well if items are reordered and "second item" is on the first position. However, if your regular expression checks for multiple items then they have to occur in the same order as in checklist. |
...
As a result, the transition will require that all the checklist items are in a status different from "open".
...
title | Warning: empty checklist and Jira regexp validator |
---|
Due to a bug in Jira regular expression validator will throw an exception if used on an empty custom field (such as Checklist Text). This means that the regular expression above will require not only that there are no items with status "open", but also that the checklist has items at all.
...
Transition will be also possible in case issue has no checklist at all.
Example 6 - block transition if no items are checked
...
(optionally requiring non-empty checklist)
One of the following regular expressions can be used to make the transition requre at least one checked item and optionally require that checklist has at least one item. Two of them work with item statuses are disabled, create a regular expression validator for Checklist Text custom field with the following expression:
...
the other two - with statuses enabled. If you use custom statuses for checked items you will need to add them to the expression.
Code Block | ||
---|---|---|
| ||
(?s)^(?!.*\*\s+\[.*?\])|(?=.*\*\s+\[x\]).*$ |
If item statuses are enabled, use a different expression (you will need to adjust it if you have custom statuses for checked items):
Code Block | ||
---|---|---|
| ||
(?s)^(?=.*\*\s+\[x\]).*$ |
Code Block | ||
---|---|---|
| ||
(?s)^(?!.*\*\s+\[.*?\])|(?=.*\*\s+\[done|skipped\]).*$ |
Code Block | ||
---|---|---|
| ||
(?s)^(?=.*\*\s+\[done|skipped\]).*$ |
...