Error in logs caused by Calculated Number Field

I'm using the following formula

<!-- @@Formula:

if (issue.get("customfield_17937").getTime() == null) return null;
if (issue.get("customfield_17938").getTime() == null) return null;
(issue.get("customfield_17937").getTime() - issue.get("customfield_17938").getTime()) / 1000 / 3600

-->

It shows on screen and all but my logs are full with the following message

IssueIndexer:thread-3 ERROR user001 395x16093x1 zbxffj 10.244.35.64,127.0.0.1 /secure/admin/IndexReIndex.jspa [innovalog.jmcf.fields.CalculatedNumberField] CalculatedNumberField: error evaluating formula: Sourced file: inline evaluation of: ``    if (issue.get("customfield_17826").getTime() == null) return null;  if (issu . . . ''

Tried using the following but the results are not shown on screen

<!-- @@Formula:

((issue.get("customfield_17937")==null ? null : (issue.get("customfield_17937").getTime()) - (issue.get("customfield_17938")==null ? null : (issue.get("customfield_17938").getTime())) / 1000 / 3600

-->

Please note that both custom fields are Date Time Fields.

 

 

1 answer

1 accepted

This widget could not be displayed.

You need to test the return value of issue.get(...) against null, not the return value of issue.get(...).getTime() :

&lt;!-- @@Formula:
if (issue.get("customfield_17937") == null) return null;
if (issue.get("customfield_17938") == null) return null;
(issue.get("customfield_17937").getTime() - issue.get("customfield_17938").getTime()) / 1000 / 3600
--&gt;

Thanks David! We are really happy with your add-on and are happier with your support! Thanks again!

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

92 views 1 0
Join discussion

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