Workflow Validators and Conditions
Since the 7.9.0 version, it is possible to write custom validators and conditions for workflows.
The SQL+JQL query must return a boolean value (or any other convertible type) in the first column of the first row.
It supports variable substitution for the current issue id:
%issueid%
Example
This is an example for a custom validator (conditions are very similar).
We are going to write a validator to avoid to perform the Done transition between the OPEN and CLOSED statuses if the issue has no comments.
Edit the target transition and click on the Add validator button:
Select the SQL+JQL Workflow Validator option and click on the Add button:
Type the:
- Description: This is the error text message that the end users will read and the tip for the administrators to identify the validator.
- Query: select count(*) from ISSUECOMMENTS ic where ic.issueid = %issueid%. The %issueid% variable will be replaced at run time with the current issue id. Notice that the query returns a numeric value. 0 (FALSE) for no comments and >0 (TRUE) otherwise.
Click on the Add (or Update if you are editing it) button to save the changes and publish the workflow version once it be ready for production.
Test the validator: Open an issue with no comments and in the TODO status:
Then click on the Done transition button:
The users will see the validator's Description value: "Must have comments" to understand what is failing.
Now, write some comment and click on the Done button. The issue will be transitioned to the DONE status: