Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to convert a select list to numbers to use in a calculation but getting null

kazu okamoto February 12, 2025

Im trying to associate a select list field options as numbers using the variables in my automation rule but I seem to get null results. I referenced an article showing an example of this being done on Data center. Im wondering if the syntax is supposed to be different on cloud. Here is an example of what I have for 1 of my variables.

Final action is edit "Rice Score" field with  

{{#=}} {{Reach}} * {{Impact}} * {{Confidence}} / {{Effort}} {{/}}

 

Screenshot 2025-02-12 at 3.35.24 PM.png

Reach variable

{{if(equals(issue.customfield_20039.value, "1 Team"), "1", if(equals(issue.customfield_20039.value, "10 Teams"), “2”, if(equals(issue.customfield_20039.value, "Most Teams"), “5”, if(equals(issue.customfield_20039.value, “All Teams"), “10”))))}}

 

1 answer

1 accepted

1 vote
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.
February 12, 2025

Hi @kazu okamoto -- Welcome to the Atlassian Community!

First, I recommend using a Lookup Table for this type of field mapping: https://community.atlassian.com/t5/Automation-articles/Update-Create-lookup-table-action-improvements/ba-p/2427798

This would allow getting the number in one step:

{{varReachValue.get(issue.customfield_20039.value)}}

 

Next, in your smart value expression, there are some curly / slanted quotation marks, and those are likely causing problems within the nested conditional expression.

 

Kind regards,
Bill

kazu okamoto February 13, 2025

@Bill Sheboy Thanks for the suggestion. The lookup table worked perfectly for me! 

Final calculation smart value: {{#=}}{{rice.get(issue.customfield_20039.value)}} * {{rice.get(issue.customfield_20040.value)}} * {{rice.get(issue.customfield_20041.value)}} / {{rice.get(issue.customfield_20042.value)}}{{/}}

Screenshot 2025-02-13 at 11.13.59 AM.png

Like Bill Sheboy likes this
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.
February 13, 2025

Awesome; I am glad to learn that helped!  Two more things:

1) Are the fields required or could they be empty?  And if empty, what should happen?

For example, you could add default values of zero by adding a |0 default value after each get() call.

 

2) The division in the formula will produce a floating point number.  If you want manage the precision for the number of decimal places, you could add the ROUND() function: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-math-expressions/#Functions

 

For example, this would round to 2 decimal places, with the 0 defaults added in the numerator.  As there is division, dividing by zero will lead to a math error, so consider what to use for the denominator (Effort) value default.

{{#=}} ROUND( {{rice.get(issue.customfield_20039.value)|0}} * {{rice.get(issue.customfield_20040.value)|0}} * {{rice.get(issue.customfield_20041.value)|0}} / {{rice.get(issue.customfield_20042.value)}}, 2){{/}}

 

Suggest an answer

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

Atlassian Community Events