calculated number field with one decimal

hi

 

i need to show a calculated field number field with one decimal.

float result

result = aux1 + aux2 +aux3+ aux4+ aux5;
return result:

 

but always shows me an integer number.

4 answers

0 vote

What add-ons are you using to do the scripting?

JIRA Misc Custom Fields ->calculated-number-field

0 vote
Steven Behnke Community Champion Jun 27, 2016

Can you post us the entire script?

<!-- @@Formula:

float result=0;
Object btn1 = issue.get("customfield_12128");
Object btn2 = issue.get("customfield_12129");
Object btn3 = issue.get("customfield_12130");


float aux1 = 0;

float aux2 = 0;
float aux3 = 0;


if( btn1 != null && btn1.toString().equals( "De 1 a 2 areas/ usuarios" ) ) { aux1 = 1/2; }
if( btn1 != null && btn1.toString().equals( "De 3 a 5 áreas /usuarios" ) ) { aux1 = 2; }
if( btn1 != null && btn1.toString().equals( "De 6 a más" ) ) { aux1 = 3; }

if( btn2 != null && btn2.toString().equals( "Interno" ) ) { aux2 = 1/2; }
if( btn2 != null && btn2.toString().equals( "Externo" ) ) { aux2 = 2; }

if( btn3 != null && btn3.toString().equals( "Política" ) ) { aux3 = 2; }
if( btn3 != null && btn3.toString().equals( "Reglamento" ) ) { aux3 = 2; }
if( btn3 != null && btn3.toString().equals( "Circular" ) ) { aux3 = 1; }
if( btn3 != null && btn3.toString().equals( "Doc. Corp. / Man. usuario / Metodologia" ) ) { aux3 = 1/2; }

result = aux1 + aux2 +aux3;
return result;
-->

 

help please

0 vote
Steven Behnke Community Champion Jun 27, 2016

I cannot properly test this at the moment but this may work. I made some changes and I added a "format" block at the end. Please try this out and report back any issues – 

&lt;!-- @@Formula:
double result=0;
Object btn1 = issue.get("customfield_12128");
Object btn2 = issue.get("customfield_12129");
Object btn3 = issue.get("customfield_12130");
double aux1 = 0;
double aux2 = 0;
double aux3 = 0;
if( btn1 != null &amp;&amp; btn1.toString().equals( "De 1 a 2 areas/ usuarios" ) ) { aux1 = 0.5; }
if( btn1 != null &amp;&amp; btn1.toString().equals( "De 3 a 5 áreas /usuarios" ) ) { aux1 = 2.0; }
if( btn1 != null &amp;&amp; btn1.toString().equals( "De 6 a más" ) ) { aux1 = 3.0; }
if( btn2 != null &amp;&amp; btn2.toString().equals( "Interno" ) ) { aux2 = 0.5; }
if( btn2 != null &amp;&amp; btn2.toString().equals( "Externo" ) ) { aux2 = 2.0; }
if( btn3 != null &amp;&amp; btn3.toString().equals( "Política" ) ) { aux3 = 2.0; }
if( btn3 != null &amp;&amp; btn3.toString().equals( "Reglamento" ) ) { aux3 = 2.0; }
if( btn3 != null &amp;&amp; btn3.toString().equals( "Circular" ) ) { aux3 = 1.0; }
if( btn3 != null &amp;&amp; btn3.toString().equals( "Doc. Corp. / Man. usuario / Metodologia" ) ) { aux3 = 0.5; }
result = aux1 + aux2 +aux3;
return result;
--&gt;
&lt;!-- @@Format:
numberTool.format('0.0', value)
 --&gt;
&lt;!-- @@Format:
numberTool.format("0.0", value)
 --&gt;

you should use the double quote marks in stead of the single ones

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,321 views 14 20
Join discussion

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot