Using IF statement in Misc Custom Fields for Total Number

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

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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Apr 30, 2018 in Marketplace Apps

Why moving to Confluence Data Center is only a job half-done

Confluence Data Center is a deployment option that was designed for performance at scale. In other words, Confluence will handle increased traffic much reliably in a clustered environment and yo...

225 views 0 6
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