Code for Calculated Number Field

Elaine July 31, 2014

Hi,

I am trying to create a calculated number field that will add the results of three new custom fields I have created.

The three new custom fields are all Number Fields:

Value to us (Custom Field Id 10502)

Value to customer (Custom Field Id 10503)

Value to general public (Custom Field Id 10505)

These fields are in each user story and the value is different and entered manually in each user story.

I have then created a custom Calculated Number Field "Total Value" from the add on Jira Misc, to show the calculation of the total value of the above fields (10502+10503+10505). I have typed the code into the description, but there appears to be something wrong.

I have checked out numerious Q&A pages about this issue and I have tried a few different formulas, this is the one that I am currently using:

<!-- @@Formula:

((issue.get("customfield_10503") != null ? Integer.parseInt(issue.get("customfield_10503").getValue()) ) +

((issue.get("customfield_10502") != null ? Integer.parseInt(issue.get("customfield_10502").getValue()) ) +

((issue.get("customfield_10505") != null ? Integer.parseInt(issue.get("customfield_10505").getValue() )

-->

The code seems to be good, but it is not returning a value for any of the custom fields.

Would you be able to help me with this?

Thanks

Elaine

1 answer

1 accepted

0 votes
Answer accepted
Elaine July 31, 2014

Apologies, I meant to send this as an issue direct to Atlassian, not as a question here!! So it turns out that my code was correct, I could also use the following code:

<!-- @@Formula: 
(issue.get("customfield_10503") != null ? issue.get("customfield_10503") : 0) + 
(issue.get("customfield_10502") != null ? issue.get("customfield_10502") : 0 + 
(issue.get("customfield_10505") != null ? issue.get("customfield_10505") : 0) 
-->

The problem was with one of my custom fields, I'm not sure what was wrong with it, but once I deleted it and created a new custom field and added that, it worked!!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events