Calculated Number Filed formula not working

Nanda May 16, 2017

Iam adding 3 custom filed values and dividing with another custom filed value. It is working with dividing by lower value, but not with higher value.

Adding cf1+cf2+cf3 and assigning the value to an integer variable "number".

Ex - If the sum of cf1+cf2+cf3 is 6. If the cf4 value is 3, then works fine. If the sum of 3 variables are lesser , then it returns 0.0. Can you please help to fix this.

<!-- @@Formula:
double a = 0;
Object cf1 = issue.get("customfield_10203");
Object cf2 = issue.get("customfield_10204");
Object cf3 = issue.get("customfield_10205");
Object cf4 = issue.get("customfield_10207");

int number = ((cf1 != null ? Integer.parseInt(cf1.toString()) : 0 )) +
((cf2 != null ? Integer.parseInt(cf2.toString()) : 0 )) +
((cf3 != null ? Integer.parseInt(cf3.toString()) : 0 )) ;
a=number/((cf4 != null ? Integer.parseInt(cf4.toString()) : 0 )) ;
return a;
-->

<!-- @@Format:
numberTool.format("#0.0",value);
-->

1 answer

0 votes
Jack Nolddor _Sweet Bananas_ June 22, 2017

Try replacing int and Integer, with double and Double.

Since a division of integer returns an integer.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events