Forums

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

How to sum 4 custom fields into 5th scripted field

Indra
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!
January 19, 2023

Hi All,

The fields have to be called: "Calculated business value" and "Calculated technical value" and they have to be scripted fields.

The logic for these scripted fields is as follows:

----------------------------------------------------------------------------------------------------------------------------------------------------------------

For the "Calculated business value" field, you have to add the values of the following fields:
>Revenue & Monetization
>Customer Experience
>Efficiency Impact
>Priority

Currently these fields have values in a drop-down list that goes from P1 to P5, to make the sum of the 4 fields we have to take into account that each PX has the following value:
>P1 = 8
>P2 = 5
>P3 = 3
>P4 = 2
>P5 = 1
>None = 0

Illustrative example: If "Revenue & Monetization" is worth "P1 - Huge Impact", "Customer Experience" is worth "P2 - High Impact", "Efficiency Impact" is worth "P3 - Medium Impact" and "Priority" is worth "P5 - Minor Impact", then We would have a sum of 8+5+3+1 and the value of the field "Calculated business value" would be 17.

Can you please help me this.

1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
Nic Brough -Adaptavist-
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.
January 19, 2023

Welcome to the Atlassian Community!

https://library.adaptavist.com/entity/populate-a-scripted-field-with-the-sum-of-all-values-added-or-updated-in-a-number-field does the basics of what you need.

But, the field you are reading the values from will need to be calculated, not just read.

I'm assuming your source field is a select list (drop-down).  When you use getCustomFieldValue() on a select list, you will get an "option" object from it, which you will need to translate.  For this script, you should be able to do stuff like

def read-field = issue.getCustomFieldValue("my field").getName()
def px = 0

if ("P1".equals (read-field) ) then px = 8
if ("P2".equals (read-field) ) then px = 5

and so on.

TAGS
AUG Leaders

Atlassian Community Events