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

This widget could not be displayed.

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
Community showcase
Published Aug 22, 2018 in Marketplace Apps

How a Marketplace app tech team is achieving gender diversity

Hello! My name is Genevieve Blanch, and I'm the Marketing Manager at RefinedWiki, creators of apps to give teams the tools to customize Atlassian platforms. Currently, 44% of the tech team at Re...

513 views 3 18
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