How to get the index of a dropdown field?

roberto_sc April 15, 2024

I want to create an automation to populate a numeric Importance field based on the index of the dropdown fields Severity and Frequency like so:

Importance = Severity * Frequency 

where the Severity values "Minor", "Major" and "Critical" are converted into their index in the dropdown (that is, Minor = 1, Major = 2...).

My automation Edit Field step looks like this:

{{#=}}{{issue.Severity}} * {{issue.Frequency}}{{/}}

but these are obviously translated into their value texts, not their indices.

Is there a way for me to get the index of a dropdown value? If not, how do I set variables based on dropdown values and use them to do the math?

3 answers

3 accepted

1 vote
Answer accepted
John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 15, 2024

Hi Roberto,

We do something similar and below is an example. There might be a more efficient way of doing it, but I created a Branch for each value in the Severity field (in my example it is the Impact field). Then I use the numeric value in the calculation of the Importance (in my case, Risk Score). Hope that helps. Ignore the variable I created, I had to do some other more complicated stuff with it. 

Screenshot.png

0 votes
Answer accepted
roberto_sc April 17, 2024

To anyone interested, this is what worked for me:

{{#=}}
{{if(not(exists(issue.Severity.value)),0)}}
{{if(equals(issue.Severity.value,"Trivial"),1)}}
{{if(equals(issue.Severity.value,"Minor"),2)}}
{{if(equals(issue.Severity.value,"Major"),3)}}
{{if(equals(issue.Severity.value,"Critical"),4)}}
*
{{if(not(exists(issue.Frequency.value)),0)}}
{{if(equals(issue.Frequency.value,"Rare"),1)}}
{{if(equals(issue.Frequency.value,"Occasional"),2)}}
{{if(equals(issue.Frequency.value,"Frequent"),3)}}
{{if(equals(issue.Frequency.value,"Permanent"),4)}}
{{/}}

 I'm not sure this is as succinct as it could be as I don't know this syntax well. 

I feel I should have done the lookup table as described in the other answer, though.

0 votes
Answer accepted
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 16, 2024

Hi @roberto_sc 

You could do this using conditional logic (to return the value for the fields) or use lookup tables to translate the fields into their numeric values.

Then, perform the calculation with a math expression.

Kind regards,
Bill

Suggest an answer

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

Atlassian Community Events