calculated field not working

t April 23, 2015

Hi, just wondering what is wrong in my code

 

<!-- @@Formula:
if (issue.issueTypeObject.name == "Specials"){
if (issue.get("resolutiondate") == null || issue.get("customfield_10007")==null){
  return null;
  }
else if ((issue.get("resolutiondate").getTime() - issue.get("customfield_10007").getTime()) / (1000*60*60*24) <1){
   return 0;
} else {
return (issue.get("resolutiondate").getTime() - issue.get("customfield_10007").getTime()) / (1000*60*60*24)
}
} else {
if (issue.get("resolutiondate") == null || issue.get("customfield_10002")==null){
return null;
}
else if ((issue.get("resolutiondate").getTime() - issue.get("customfield_10002").getTime()) / (1000*60*60*24) <1){
return 0;
} else {
return (issue.get("resolutiondate").getTime() - issue.get("customfield_10002").getTime()) / (1000*60*60*24);
}
}   
-->

3 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
t April 26, 2015

Fixed, the problem was with the calling of issue type..

Correct way to call issue type (which wasnt working before as my if statements wernt properly structured) (capital I in IF and E for else.)

issue.get("issuetype") == "Custom Issue Name"

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.
April 26, 2015

You're also missing a semicolon at the end of one of the return statements. 

t April 26, 2015

really? i dont see any im missing.. but i also tried this and this didnt work either... <!-- @@Formula: if (issue.issueTypeObject.name == "Specials") { if (issue.get("resolutiondate") == null || issue.get("customfield_10007")==null) return null; else if ((issue.get("resolutiondate").getTime() - issue.get("customfield_10007").getTime()) / (1000*60*60*24) <1) return 0; else return (issue.get("resolutiondate").getTime() - issue.get("customfield_10007").getTime()) / (1000*60*60*24); } else { if (issue.get("resolutiondate") == null || issue.get("customfield_10002")==null) return null; else if ((issue.get("resolutiondate").getTime() - issue.get("customfield_10002").getTime()) / (1000*60*60*24) <1) return 0; else return (issue.get("resolutiondate").getTime() - issue.get("customfield_10002").getTime()) / (1000*60*60*24); } -->

t April 26, 2015

I have even tried putting them in functions and calling the functions, but that did not work either.. the only thing i can possibly think of is that issue.issuetypeobject.name is wrong, i am using latest jira perhaps this has been updated since 2011?

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.
April 23, 2015

Did you look in atlassian-jira.log for errors?
I see at least one problem: you have several "Else" statements (with an uppercase E).

t April 26, 2015

Wasn't aware the code was case sensitive! also i dont think im able to check the log as our instance is hosted externally and i dont have access to that server just jira admin. tried using lower case elses and ifs' still no luck.. cant understand what im doing wrong

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events