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 Sign up to answer
Community showcase
Published Monday in Jira Ops

Jira Ops Early Access Program Update #1: Announcing our next feature and a new integration

Thanks for signing up for Jira Ops! I’m Matt Ryall, leader for the Jira Ops product team at Atlassian. Since this is a brand new product, we’ll be delivering improvements quickly and sharing updates...

468 views 0 9
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