Workflow conditions
A Scripted Condition decides whether Jira offers a transition at all. When it's false, Jira hides the transition: people don't see a move they aren't allowed to make.
Applies to: Script Master for Jira Β· Cloud, company-managed and team-managed spaces
A condition is a Jira expression that Jira evaluates. You can build it from checks without writing code, or write the expression yourself. Jira runs it, so a condition works without the Companion App.
A condition must return a booleanβ
| The expression returns | What happens |
|---|---|
true | The transition is available. |
false | The transition is hidden. |
| A string, a number or any other value | The transition is hidden. The value isn't shown anywhere. |
| Nothing, because the expression failed | The transition is hidden. |
A condition can't show a message. To block a transition and tell the person why, use a validator.
Variables in a conditionβ
| Variable | What it holds |
|---|---|
user | The person Jira checks the transition for |
issue | The work item |
project | The space of the work item |
transition | The transition being checked |
workflow | The workflow that holds the condition |
config | The rule's saved configuration |
groupOperator | How this condition joins the others on the transition: AND, OR, or null when it's the only one |
customerRequest, serviceDesk | The request and its service desk, on Jira Service Management transitions only |
A condition has no originalIssue. Only a validator gets it, because only a validator runs after the transition screen is filled in.
When a condition fails to evaluateβ
If Jira can't evaluate the expression, it hides the transition. Script Master counts these failures in the Last 7 days column of the Workflows tab.
Examplesβ
All three examples are also in the editor's Snippets.
Allowed work typesβ
The transition is visible only for the listed work types.
['Bug', 'Task'].includes(issue.issueType.name)
Comment from the person moving itβ
The transition is visible only when the person has commented on the work item.
issue.comments
.filter(c => c.author.accountId == user.accountId)
.length > 0
Stricter when combined with ORβ
When this condition is one of several alternatives, it asks for more.
groupOperator == 'OR'
? issue.assignee != null && issue.priority.name == 'Highest'
: issue.assignee != null
Relatedβ
- Add a condition: put a condition on a transition.
- Test a rule on a work item: check whether a person would see the transition.
- Workflow validators: block a transition with a message instead.