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

This widget could not be displayed.

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
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

175 views 2 0
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