Using IF statement in Misc Custom Fields for Total Number

James Pate March 18, 2014

Hi,

I'm trying to use JIRA Misc Custom Fields and IF statements to determine the following:

If Customfield_10104 = 1

and Customfield_10105 = 1

return 1

If Customfield_10104 = 1

and Customfield_10105 = 5

return 9

Basically i'm trying to replace an existing spreadsheet that uses X/Y calculations (i.e. bespoke non-logical calculations) but can't get the IF statement to work, i could return the value of the customfield, and customfield_10104 + customfield_10105 = total but this is just adding them together but i need it to return a bespoke answer...HELP!

Many thanks

1 answer

0 votes
David _old account_
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.
March 18, 2014

Assuming your custom fields are number fields:

if (issue.get("customfield_10104")==1 && issue.get("customfield_10105")==1)
  return 1;
else if (issue.get("customfield_10104")==1 && issue.get("customfield_10105")==5)
  return 9;

return 0; //or any other default value

If your custom fields are text fields, you'll need to do text comparisons:

if ("1".equals(issue.get("customfield_10104")) && "1".equals(issue.get("customfield_10105")))
  return 1;
if ("1".equals(issue.get("customfield_10104")) && "5".equals(issue.get("customfield_10105")))
  return 9;

return 0; //or any other default value

or else first convert the customfield values to integers using Integer.parseInt(issue.get("customfield_10104"))

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events