text formula question

hi,  

I want to create an identification formula, 

One Calculated number field (ID:12002) is created and works well.

I want to convert the value into text as 

if value is null then null

if value >4 then "Over 4 wks"

if value >2 then "2~4 wks"

if value >0 then "0~2 wks"

 

I tried to use below 2 method, but failed

<!-- @@Formula:
Integer i = issue.get("customfield_12002");
if (i==null) return null;
if (i > 4) return "Over 4 wks";
if (i > 2) return "2~4 wks";
return "0~2 wks";
-->

or 

<!-- @@Formula:
Integer i = issue.get("customfield_12002");
if (i==null) return null;
else if (i > 4) return "Over 4 wks";
else if (i > 2) return "2~4 wks";
else return "0~2 wks";
-->

 

 

I refered document as below, however, it doesn't work, please help, thank you, 

Quick reply, before you post your question on Answers: 

I assume you already have a calculated number field. Let's say its ID is 12345, hence its name is "customfield_12345".

In your Calculated Text Field, you would do something like:

 

<!-- @@Formula:
Integer i = issue.get("customfield_12345");
if (i==nullreturn null;
if (i==0return "low";
if (i==2 || i==3return "medium";
return "high";
-->

 

 

1 answer

I modified the code as below, then it works

<!-- @@Formula:
if (issue.get("customfield_12002")==null) return null;
else if (issue.get("customfield_12002") > 4) return "Over 4 wks";
else if (issue.get("customfield_12002") > 2) return "2~4 wks";
else return "0~2 wks";
-->

 

Suggest an answer

Log in or Join to answer
Community showcase
Emilee Spencer
Published Friday in Marketplace Apps

Marketplace Spotlight: DeepAffects

Hello Atlassian Community! My name is Emilee, and I’m a Product Marketing Manager for the Marketplace team. Starting with this post, I'm kicking off a monthly series of Spotlights to highlight Ma...

56 views 0 3
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
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