MISC Custom Fields: Calculated text field based on issuetype

Shreya Rawal April 9, 2015

I am trying to populate a text field based on issue type:

<!-- @@Formula:
String s = issue.get("issuetype").getName();
if (s == "Other") return "This is of issue type other";
-->

s is getting populated with "Other", however, when I compare it in if statement I do not see the output. 

Thanks!!

5 answers

1 accepted

1 vote
Answer accepted
Peter Bengov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 16, 2015

You can cast the value, that should work

if (s.equals("Change Relationship")) 
	return (int)issue.get("customfield_11501");
1 vote
Peter Bengov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 9, 2015

Try 

s.equals("Other")
0 votes
Shreya Rawal April 16, 2015

Yup, that worked and it's Java implementation. Things makes so much more sense now laugh

0 votes
Shreya Rawal April 16, 2015

Hi Peter,

I am trying to calculate a number field but I do not want to display the decimal point. Is there a way to convert a field value to whole number?

This is giving no result. customfield_11501 value is 51 and it displays 51.0 when I display it as it is.

if (s.equals("Change Relationship"))
{
value=issue.get("customfield_11501");
return numberTool.format(value);
}

 

Thanks!!

0 votes
Shreya Rawal April 10, 2015

Awesome! Thanks Peter smile

Peter Bengov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 10, 2015

You are welcome

Suggest an answer

Log in or Sign up to answer