Jira Automation smart value
and, or, not in Jira Automation conditions: examples
and() is true when both conditions are true, or() when at least one is, and not() flips a condition. Use them inside {{#if()}} to build rules such as a note for work items with a due date and labels.
Syntax
{{and(condition1, condition2)}}
{{or(condition1, condition2)}}
{{not(condition)}}
Arguments
| Argument | What it is | Required |
|---|---|---|
condition1, condition2 | Smart values that return true or false, such as comparisons, exists() or equals() | yes |
Works on
- Conditions: comparisons, exists(), equals(), isEmpty and similar
- Returns: true or false
Examples
{{#if(and(issue.comments.size.gt(1),issue.comments.size.lt(5)))}}Moderately active{{/}}Match a range: more than one and fewer than five comments.
Result:
Moderately activeRun on Jira Cloud on .
{{and(issue.labels.size.gt(0), issue.comments.size.gt(5))}}Both checks must pass: labels yes, more than five comments no.
Result:
falseRun on Jira Cloud on .
{{or(issue.labels.size.gt(5), issue.comments.size.gt(1))}}One passing check is enough.
Result:
trueRun on Jira Cloud on .
{{not(issue.labels.isEmpty)}}Turn an emptiness check around.
Result:
trueRun on Jira Cloud on .
{{#if(or(issue.comments.size.gt(20),issue.labels.size.gt(1)))}}Needs a look{{/}}Flag a work item that is either heavily discussed or carries several labels.
Result:
Needs a lookRun on Jira Cloud on .
{{#if(and(exists(issue.duedate),not(issue.labels.isEmpty)))}}Due {{issue.duedate.format("dd MMM")}} and labelled{{/}}Chain three functions and a date format into one message.
Result:
Due 15 Dec and labelledRun on Jira Cloud on .
Pitfalls
- The or() doc example compares
issue.comments, which is a list, withgt(20). Compare the count instead:issue.comments.size.gt(20). - Comparisons on a field that does not exist, such as Votes on a site without that field, print nothing rather than failing, so a condition built on them is silently never true.
Related
- {{#if}} … {{/}}
- equals() and exists() in conditions
- gt(), gte(), eq(), lt(), lte()
- size and isEmpty on lists
- isEmpty() and isNotEmpty()