Forums

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

Using conditional logic in variables to create "Score"

Brian Gauthier
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 14, 2024

I'm trying to use variables to associate numercial values to values in other fields.  I have four variables.  Reach, Urgency, Impact, and Executive Importance.   Each of those fields has selections such as "High", "Medium", "Low".    I want to associate numerical values to those selections for each of the 4 fields and then apply a summation to get a total score.  

 

I've tried using code like this in the smart value section of creating a variable , but I'm getting an error.   Here's an example of trying to apply this for the reach variable (customfield_10060)

 Name: reachValue

SmartValue:

 

{{#=}}

{{#if(equals(issue.customfield_10060, "Very High"))}}13

{{else}}{{#if(equals(issue.customfield_10060, "High"))}}8

{{else}}{{#if(equals(issue.customfield_10060, "Medium"))}}5

{{else}}{{#if(equals(issue.customfield_10060, "Low"))}}3

{{else}}{{#if(equals(issue.customfield_10060, "Very Low"))}}1

{{else}}0{{/}}{{/}}{{/}}{{/}}{{/}}

{{/}}

 

Any ideas what would make this work?

3 answers

1 vote
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.
August 15, 2024

Hi @Brian Gauthier -- Welcome to the Atlassian Community!

As others have noted, that is the incorrect syntax for a smart value condition as {{else}} is not valid.

For this type of rule, I recommend using a Lookup Table to convert the values to the numbers: https://community.atlassian.com/t5/Automation-articles/Update-Create-lookup-table-action-improvements/ba-p/2427798

When you do that, use the value attribute of the fields so the display value is the key.  For example:

  • action: Lookup Table
    • name: varReachToScore
    • row:
      • key: Very Low
      • value: 1
    • row:
      • key: Low
      • value: 3
    • row:
      • key: Medium
      • value: 5
    • row:
      • key: High
      • value: 8
    • row:
      • key: Very High
      • value: 13
  • example action to use the lookup
{{varReachToScore.get(issue.customfield_10060.value)}}

 

Create a Lookup Table for each conversion value.  Then if you wanted to sum that, that might be this, substituting in your correct custom fields:

{{#=}}
{{varReachToScore.get(issue.customfield_10060.value)}}
+ {{varUrgencyToScore.get(issue.urgency custom field.value)}}
 + {{varImpactToScore.get(issue.impact custom field.value)}}
+ {{varExecutiveImportanceToScore.get(issue.executive importance custom field.value)}}{{/}}

 

As a observation about your calculation, having a parameter such as "Executive Importance" is often an indication / smell of a process problem, where opinions rather than repeatable methods are impacting product management.  Perhaps discuss that with your team coach and product management team.

 

Kind regards,
Bill

0 votes
Boris Zozoulia
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.
August 14, 2024

Hello @Brian Gauthier 

As per the docu - u have referenced
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.

 

In other words - I understand - conditional logic smart values cannot be used in the creation of smart variables.

 

and then also - the "else" problem, mentioned by @Trudy Claspill 

0 votes
Trudy Claspill
Community Champion
August 14, 2024

Hello @Brian Gauthier 

Welcome to the Atlassian community.

What is the error you get?

Looking at the documentation for conditional logic I don't see any indication that {{else}} is supported. Did you see that syntax in an example somewhere?

Suggest an answer

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

Atlassian Community Events