Calculate Value for custom field from other custom fields

Dani Miles February 22, 2023

I have 4 single select list custom fields all with the same values which are alphanumeric:

  • 0 (No impact)
  • 1 (Negligible)
  • 2 (Minor)
  • 3 (Indirect)
  • 4 (Moderate)
  • 5 (Major)

I want to calculate a new numeric field from these values, I was hoping to do something like below but it is not working. I am not sure if the main problem is being the alphanumeric field values I am trying to pull as I can't even seem to pull one custom field value into my new field. 

{{#=}}{{issue.customfield.asNumber}} + {{issue.customfield.asNumber}} +{{issue.customfield.asNumber}} +{{issue.customfield.asNumber}} + {{/}}

 

I am not interested in any add-on's just want to know if I can do this with smart values. 

2 answers

2 accepted

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.
February 22, 2023

Hi @Dani Miles 

As your single-select values contain a number and text, you could extract the number before the operations, such as using the left() function: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/#left-int-length-

For example:

{{issue.customfieldA.value.left(1).asNumber|0}}

I added a default of 0 to the end of the expression.

Kind regards,
Bill

Dani Miles February 23, 2023

Thanks Bill, this worked perfectly. I had tried {{issue.summary.charAt(1)}} which hadn't worked but this worked perfectly. 

Like Bill Sheboy likes this
0 votes
Answer accepted
Najm Polaris
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 22, 2023

Hi @Dani Miles , 

the alphanumeric value might be the issue. Try with just number field and it should work. 

Sum of smart values 

{{#=}}{{issue.customfield1}}+{{issue.fcustomfield2}}+...{{/}} 

Dani Miles February 23, 2023

Thanks Najm, 

You were right it didn't like the alpha characters I just needed a way to strip them. 

Kinchik May 14, 2024

Playing the sugar rush online casino at Weiss Bet online casino is an absolute treat. The candy-themed graphics are vibrant and the cascading reels add a fun twist to the gameplay. I love how the bonuses and free spins pop up frequently, making each session exciting and rewarding. It’s definitely one of my go-to games when I want to unwind and enjoy some sweet wins.

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