Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Ternary operator (or if/else) with smart values

Chad Waldman March 10, 2023

I'm looking to create a smartvalue that would say:

If (field.match(".+Multiple.+")) Then 20 Else 2

I could do:
{{#if(issue.field.match(".+Multiple.+"))}}20{{/}}

however I don't know how to do the fallback value. 

Is this possible with a smart value?

FWIW, I already know I can do this in Automation with an If/Else.

2 answers

0 votes
Aron Kuch November 3, 2023

I used the double-if and it seems to be working. 

 

{{#if(equals(issue.issuetype.name, "Large"))}}10000{{/}}
{{#if(equals(issue.issuetype.name, "Program"))}}10002{{/}}
0 votes
James Navin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 12, 2023

Hi @Chad Waldman ,

Ternary expressions aren't supported in Smart Values at the moment.

To achieve what you're looking for there are a couple of options:

  1. Set the value to the "fallback" and then use the 'if' to override it
  2. Use a second 'if' with a `not()` function to set the fallback for the negative case

 

Hope that helps,

James

Chad Waldman March 12, 2023

Thank you for the suggestions. 

I am not following your first recommendation. Can you please write an example. 

 

For your second suggestion, are you recommending:

{{#if(issue.field.match(".+Multiple.+"))}}20{{/}}{{#if(not(issue.field.match(".+Multiple.+")))}}2{{/}}

I haven't tried two conditionals in one expression but this sounds interesting.  

MJCorcoran August 24, 2023

I needed to put an email address (created from values in the issue) into the ticket comment, but needed to use 2 different logics to create the address based on whether there was a middle initial (customfield 12034 in this example). I followed the 2nd suggestion above and came up with something like this. What I am trying to figure out is how to get them all in one line/statement so the answers don't appear spaced differently depending on the logic.

{{#if(equals(issue.customfield_12034.value,"NA"))}}Email Address: {{issue.customfield_11884.left(1)}}{{issue.customField_11885}}@kennedy-center.org {{/}}


{{#if(not(issue.customfield_12034.value,"NA"))}}
Email Address: {{issue.customfield_11884.left(1)}}{{issue.customfield_12034}}{{issue.customField_11885}}@kennedy-center.org {{/}}

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events