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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Ternary operator (or if/else) with smart values

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

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.
Mar 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

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.  

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
Site Admin
TAGS
AUG Leaders

Atlassian Community Events