Excerpt |
---|
A workflow validator which ensures that the specified field has a value during a transition. |
If the specified field is empty, an error message is displayed and the user is forced to input a value. You can customize the error message to be displayed when the validation fails.
To add 'Field is required Validator' to a transition:
Click
Edit
for the workflow that has the transition you wish to configure the validator on.In the
Workflow Designer
, select the transition.Click on
Validators
in the properties panel.Click on
Add
validator
.Select
Field is required Validator
from the list of validators.Select the field name in the
Field
drop-down.Input a message in the
Error message
field to customize the error message.Click on
Add
to add the validator to the transition.
When you add this validator to a transition and trigger the transition, the add-on checks for a value in the selected field. If no value is found, then an error message (configured/default) is displayed.
Note that this validator does not work for the following fields: Security Level, Watchers, Epic Color, Epic Name, Epic Status, Raised during.
Also, some custom fields from other apps, like Team of Jira Portfolio, though available in the list are not supported because of certain limitations (of the apps).
Validator Scope
Check this option if you want validation to occur only in certain cases, such as if the issue is of a certain issue type, has certain field values, or more generally satisfies an arbitrary Jira expression.
Use case
A typical use of this workflow validator is to validate that the field of the issue has a value during the transition. Consider a use case where you want to check that the “Approvers” field is not empty when sending the ticket for approvals. To configure this:
Add the “Field Required Validator” to the “Send for Approval” transition
Select the “Approvers” field
Save the validator
Publish the workflow
Avoid Jira expressions errors
When a Jira expression throws an error, Jira considers the result as false
and hence the workflow validator fails. The best way to avoid errors in your Jira expressions is to test your Jira expressions against an issue using the "Jira expression tester" before saving the validator. Here are typical problems you need to look out for:
null
values: If your Jira expression returns null
it is considered a non-boolean value and hence Jira returns an error. For example, to check that the issue is assigned, if you provide the Jira expression as:
Code Block |
---|
issue.assignee |
when tested against an issue that is unassigned the expression returns null
. In such cases, the easiest is to use two logical not operators (!!) to return true
if the issue is assigned ( !issue.assignee returns false
hence !! issue.assignee will return true
when the issue is assigned).
Code Block |
---|
!! issue.assignee |
You can also write a Jira expression to check that the result is not null
like this:
Code Block |
---|
issue.assignee != null |
If your Jira expression accesses properties of an object that is null
, then your Jira expression and thereby your workflow validator fail with an error. For example, to check that the issue's parent is a Story if you provide the Jira expression:
Code Block |
---|
issue.parent.issuetype.name == "Story" |
when tested against an issue without a parent, the Jira expression will return an error "Type null does not have any properties". To handle this you should include an expression to test that the issue has a parent.
Code Block |
---|
!! issue.parent && issue.parent.issuetype.name == "Story" |