Excerpt |
---|
A workflow condition |
that hides/shows a transition based on the result of Jira expression. |
The transition to which the condition is added will be available only if the Jira expression returns true
. 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) Condition' to a transition:
Click Edit for the workflow that has the transition you wish to configure the condition on.
In the Workflow Designer, select the transition.
Click on
Conditions
in the properties panel.
Click on
Add
condition
Add condition
.Select
Build-your-own (scripted)
Condition
from Condition
from the list of conditions.Click on
Add
to add the condition on the transition.
Related links :
Refer to the Use cases for conditions page for use cases for this condition.
For information on how to write a Jira expression, see How to insert information using Jira expressions.Input a Jira expression in the
Jira expression
field.For information on how to write a 'Jira expression' see How to insert information using Jira expressions.
Click on
Add
to add the condition to the transition.
Common mistakes while using this condition:
Filter by label (Content by label) | ||||||
---|---|---|---|---|---|---|
|
Other related articles
When you add this condition to a transition, the add-on checks the result of the Jira expression. If the expression
returns true
, the transition will be available to the user, and if it
returns false
or a non-boolean value, the
transition will be hidden.
title | Avoid Jira expressions errors |
---|
When a Jira expression throws an error, Jira considers the result as false
and hence the workflow condition 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 condition. Here are typical problems you need to look out for:
Syntax errors: Currently, syntax errors are not logged in the JMWE logs when conditions and validators are run (because of a Jira bug). So you will never know why the condition failed if it's because of a syntax error. Testing the Jira expression, however, will show syntax errors.
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 |
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).Use case
A typical use of this workflow condition is to hide the transition when a field of the issue has a specific value or the current user belongs to a specific group.
Consider a use case where you want to show the “Approve” transition only when the current user is in the “Approvers” field. To configure this:
Add the “Build-your-own (scripted) condition” to the “Approve” transition
Input the following code under “Jira Expression”
Code Block !! issue.
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 condition 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.
customfield_10002 && issue.customfield_10002.some(it => it == user)
Note it is suggested to use the “Issue Fields” tab of the Jira expression editor, select the field from the list and the Jira expressions editor help system shows examples on accessing and testing the field value.
See https://innovalog.atlassian.net/wiki/x/GIDmOw for more uses cases for this condition.