Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Sum 2 number fields

Fabien GIQUIAUD May 30, 2022

Hi everyone. 

My question seems simple but I'm lost with script and automation so I would like some help if possible ...

I want to sum 2 number fields in a third field. It's limited to one Service Desk project and it's very basic. For example:

Field A = 1

Field B = 4

Total cost = 5 (sum of A + B)

How can I do it simply? 

Thank in advance for your help. 

1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
Alexander Bondarev
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.
May 30, 2022

Hi, @Fabien GIQUIAUD !

Agree with you - it is possible using Scriptrunner,

Check the similar question, there you can fing a lot of examples.

Fabien GIQUIAUD May 31, 2022

Hi @Alexander Bondarev 

Thanks for the quick answer. Sorry I am new to scripts, I looked at the other question and tried to reproduce the script, but I have an error on the "+" symbol (I guess)

> Cannot find matching method java.lang.Object#plus(java.lang.Object)

This is what I put in:

 

import com.atlassian.jira.component.ComponentAccessor

def A = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Cost of training (€)")

def B = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Extra costs")

return issue.getCustomFieldValue(A) + issue.getCustomFieldValue(B)
P.S: I am on Jira server and not cloud
TAGS
AUG Leaders

Atlassian Community Events