Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

JMCF set text based on value

Antonio Caeiro September 16, 2022

Hi,

have the following code in production:

if (issue.get("customfield_14203")==null || issue.get("customfield_10102") == null)
return null;
return (issue.get("customfield_14203") - issue.get("customfield_10102"));

and it works fine. it returns a number of days (ex 10; -2)

Instead of this, i need to return a text, based on the value as folloiwng:

“Overdue” if the result >=0.1

else “On Time”.

 

can you please give me some help?

 

tks

Antonio

 

2 answers

1 vote
David Fischer
Community Champion
September 16, 2022

Hi @Antonio Caeiro ,

two possibilities:

- you want to create a new Calculated Text field to show Overdue or On Time, based on the calculation. For that, you can use this formula:

if (issue.get("customfield_14203")==null || issue.get("customfield_10102") == null)
return null;
return (issue.get("customfield_14203") - issue.get("customfield_10102")) >= 0.1 ? "Overdue" : "On Time";

- you want to keep your Calculated Number field as is, but simply display the value as Overdue or On Time (while sorting, searching, and exports will still be based on numbers). In that case, you can use the "Velocity Template" and "List View Velocity Template" configuration options with that code:

#if ($value >= 0.1)
Overdue
#else
On Time
#end
 
0 votes
Antonio Caeiro September 19, 2022

Hi David. It works fine. tks for the tipimage.png

Suggest an answer

Log in or Sign up to answer