Forums

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

Is it possible to Sum multiple (5 numeric fields) using the Calculated Number Field?

Jeff Bolin February 7, 2018

Is it possible to Sum multiple (5 numeric fields) using the Calculated Number Field?

I'm using the formula: 

<!-- @@Formula: (issue.get("customfield_11394") != null ? issue.get("customfield_11394") : 0) + (issue.get("customfield_11395") != null ? issue.get("customfield_11395") : 0) + (issue.get("customfield_1139") != null ? issue.get("customfield_1139") : 0) + (issue.get("customfield_11397") != null ? issue.get("customfield_11397") : 0) + (issue.get("customfield_11412") != null ? issue.get("customfield_11412") : 0) -->

 

It will add 2 fields together, why not more?

 

Thanks so much,

 

Jeff

1 answer

1 accepted

2 votes
Answer accepted
Brittany Wispell
Community Champion
February 7, 2018

Hi @Jeff Bolin what add-on are you using?

Jeff Bolin February 7, 2018

JIRA Misc Custom Fields

Jeff Bolin February 8, 2018

Is the paid for add-on better?  Can it handle adding multiple fields?

Brittany Wispell
Community Champion
February 8, 2018

I haven't seen a Jira Misc Custom Fields paid add-on. I know it is possible to do this in the add-on you have though. 

I personally use ScriptRunner, so please pardon my poor code...I would suggest adding a log.error before will help you find where the issue might be in your code. Example below. I haven't tested it but you could give it a try.

I think it might be an issue with your customfield_1139 (might be missing another #)

<!-- @@Formula: log.error("Value of field 1 is: "+issue.get("customfield_11394"));
log.error("Value of field 2 is: "+issue.get("customfield_11395")); 
log.error("Value of Field 3 is: " +issue.get("customfield_1139"));
log.error("Value of Field 4 is: " +issue.get("customfield_11397"));
log.error("Value of Field 5 is: " +issue.get("customfield_11412"));
if (issue.get("customfield_11394") == null || issue.get("customfield_11395") == null || issue.get("customfield_1139") == null || issue.get("customfield_11397") == null || issue.get("customfield_11412"))    
return null

return issue.get("customfield_11394")
+ issue.get("customfield_11395")
+ issue.get("customfield_1139")
+ issue.get("customfield_11397")
+issue.get("customfield_11412"); 
-->


 

Jeff Bolin February 8, 2018

Yikes!  Good catch :)  

I'm horrible at coding too (as you can see, lol).  

Thank you very much!  I'll let you know if it works. 

Brittany Wispell
Community Champion
February 8, 2018

Hey Jeff, 

The log.error before what you're statement will help with these things. :) I learned that early and it saves so much time! Happy coding!

Jeff Bolin February 8, 2018

I feel like such a goof.  When I corrected the field ID, it worked.  Thank you so very much @Brittany Wispell

Brittany Wispell
Community Champion
February 8, 2018

@Jeff Bolin No problem! Sometimes it just takes a second pair of eyes :) 

If you wouldn't mind accepting my answer as this questions is answered that would help me out. Thanks!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events