Jira smart values - conditional logic

The smart values listed on this page can be used with actions where text fields are involved, such as the Add comment or Send email actions. They can be used to print outputs based on conditional logic such as if or and statements.

if

Syntax

  • {{if(smartValue)}} returns true or null.

  • {{if(“string”)}} returns true or null

  • {{if(smartValue)}}Hello{{/}} returns Hello or null.

  • {{if(smartValue, “Hello”)}} returns Hello or null.

  • {{if(smartValue, "value if true", "value if false")}} allows you to add a specific value when the condition is not matched.

Example

Let’s say you have a list of issues (perhaps from a Lookup issues action), and you want to add a comment to any that have linked issues. You could use the Add comment action with the following input to add a comment to each issue that has at least one linked issue:

1 2 3 {{#if(not(issue.issuelinks.isEmpty))}} This bug has {{issue.issuelinks.size}} related tickets {{/}}

In this case, if an issue has 4 related issues, then the comment This bug has 4 related tickets would be added.

equals

Syntax

  • {{equals("string1", "string2")}} returns true if the two inputs are equal, and false if they aren’t.

  • {{equals(smartValue1, smartValue2)}} returns true if the two inputs are equal, and false if they aren’t.

Example

Let's say you have a process in your team, whereby the assignee and the reporter must be different team members for auditing purposes. You could use the Add comment action with the following input to add a comment to each issue to remind your team that this is the case:

1 2 3 {{#if(equals(issue.assignee, issue.reporter))}} Assign this issue to someone else so they can review. {{/}}

This would add the comment Assign this issue to someone else so they can review if the assignee and reporter are the same.

exists

Syntax

  • {{exists(smartValue)}} returns true or null

  • {{exists("string")}} returns true or null

Example

Let's say you have a custom field on your issues called Designer. You could use any action that prints text (such as Add comment, or Send Slack message) to inform people with the following input:

1 2 3 {{#if(exists(issue.designer))}} The designer for this issue is {{issue.designer.displayName}} {{/}}

In this case, if the field Designer has a value, your output would be The designer for this issue is (designer's name). 

not

Syntax

  • {{not(smartValue)}} returns true or false

Examples

Let’s say you have a list of issues (perhaps from a Lookup issues action), and you want to add a comment to any that have linked issues. You could use the Add comment action with the following input to add a comment to each issue that has at least one linked issue:

1 2 3 {{#if(not(issue.issuelinks.isEmpty))}} This bug has {{issue.issuelinks.size}} related tickets {{/}}

Here, the not smart value checks to see if an issue has at least one related issue. For example, if an issue has 4 related issues, then the comment This bug has 4 related tickets would be added.

and

Syntax

  • {{and(smartValue1, smartvalue2)}} returns true or false

Examples

Let's say you have a list of issues that have a Votes custom field. You could use the Add comment action to add a comment to all issues that have greater than 100 votes, and less than 150 votes:

1 2 3 {{#if(and(issue.Votes.gt(100),issue.Votes.lt(150)))}} Moderately Popular issue {{/}}

This input would add the comment Moderately Popular issue.

or

Syntax

  • {{or(smartValue1, smartvalue2)}} returns true or false

Examples

Let's say you've got a project that customers use to report bugs, and your issues have a Votes custom field. You could gather a list of issues using the Lookup issues action, and then use the Add comment action to add a comment to all issues that have either more than 100 votes, or more than 20 comments:

1 2 3 {{#if(or(issue.Votes.gt(100),issue.comments.gt(20)))}} Heavily requested issue {{/}}

Here, the if smart value checks for more than 100 votes or more than 20 comments, and adds the comment Heavily requested issue.

 

Additional Help