Our new Appfire Documentation Space is now live!

Take a look here! If you have any questions please email support@appfire.com

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 12 Next »

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 linked issues, to check for open Sprints, etc.

To add the 'Build-your-own (scripted) Validator' to a transition:

  1. Click Edit for the workflow that has the transition you wish to configure the condition on.

  2. In the Workflow Designer, select the transition.

  3. Click on Validations in the properties panel.

  4. Click on Add validation.

  5. Select Build-your-own (scripted) Validator from the list of conditions.

  6. Click on Add to add the validator on the transition.

  7. Input a Jira expression in the Jira expression field.

  8. Input a message in the Error message field to display if the configured conditions are not satisfied.

  9. For information on how to write a 'Jira expression' see How to insert information using Jira expressions.

  10. Click on Add to add the condition to the transition.

When you add this validator to a transition and trigger the transition, the add-on checks the result of the Jira expression. If it returns true the validation will pass. If it returns false or any non-boolean value, a validation error message is displayed.


Use case

A typical use of this workflow validator is to validate that the field of the issue has a specific value or the current user belongs to a specific group during the transition. Consider a use case where you want to block the user from triggering the “Approve” transition when the current user is not in the “Approvers” field. To configure this:

  1. Add the “Build-your-own (scripted) validator” to the “Approve” transition

  2. Input the following code under “Jira Expression”

    !! issue.customfield_10002 && issue.customfield_10002.some(it => it == user)

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:

    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).

    !! issue.assignee

    You can also write a Jira expression to check that the result is not null like this:

    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:

    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.

    !! issue.parent && issue.parent.issuetype.name == "Story"



  • No labels