Calculated Number Filed formula not working

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:

1 answer

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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Jul 10, 2018 in Marketplace Apps

If you’re an Atlassian app developer, you’ll want to know about Atlas Camp!

This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...

152 views 0 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you