Trying to get Resolution Time

I'm trying to get the resolution time since the SLA in Service Desk is using + / - in the time. I just need the number of days spend on a ticket. I used the following formulas. but it did not give me any result. Am I missing anything?

<!-- @@Formula: issue.get("resolved")==null ? null : (issue.get("resolved").getTime() - issue.get("created").getTime()) / 1000 / 3600 / 24 -->

<!-- @@Formula: issue.get("resolutiondate")==null ? null : (issue.get("resolutiondate").getTime() - issue.get("created").getTime()) / 1000 / 3600 / 24 -->

6 answers

1 accepted

That's because you created a Calculated Date/Time field when what you want to return is a Number (of days). So you need to create a Calculated Number Field instead.

Thanks David! It works now! I should've thought of that.

I've another field using your add-on. It's working but it throws the following error on my logs.

CalculatedDateField: error evaluating formula: Sourced file: inline evaluation of: `` org.apache.commons.lang.time.DateUtils.addDays(issue.get("customfield_13702"),1 . . . '' : Method Invocation org.apache.commons.lang.time.DateUtils.addDays

Here is the code I'm using.

<!-- @@Formula: org.apache.commons.lang.time.DateUtils.addDays(issue.get("customfield_13702"),30) -->

You're welcome.

As for your other problem, can you post the entire error? There must be another line following this one.

Can you possibly try the following SNAPSHOT release and tell me if it fixes your issue? https://innovalog.atlassian.net/secure/attachment/25267/jira-misc-custom-fields-1.5.9-SNAPSHOT.jar

Thanks David! I'm currently testing them. So far, you really need to reindex when you add a calculated field. If you don't it would still show the error.

Here are the steps I did.

1. Upload Add-On

2. Background Reindex

3. Created Custom Field

4. Background Reindex

While the Reindex is not yet finished, the logs are being filled with the

[innovalog.jmcf.fields.CalculatedDateField] CalculatedDateField: error evaluating formula: Sourced file: inline evaluation of: `` org.apache.commons.lang.time.DateUtils.addDays(issue.get("customfield_13702"),1 . . . '' : Method Invocation org.apache.commons.lang.time.DateUtils.addDays

After reindex, no sign of the error message. I haven't tried locked reindex but I would assume that the error messages would not be thrown.

When you reindex, it will compute the field for all issues. So I suspect it's because some issues have a null value in field customfield_13702

You need to protect against null values in your formula:

if (issue.get("customfield_13702")==null) return null;


Awesome! Works perfectly now! Thanks a lot David!

Error seen on logs are CalculatedDateField: formula does did return a Date object:

The correct formula is the second one.

To verify the syntax of your formula, you can look into your log gile (atlassian-jira.log) for errors.

To verify that the formula is entered in the appropriate location, replace is with: @@Formula: 1 and make sure that your field then displays "1".

Also make sure the Resolution Date field is correctly set on your JIRA issue.

Make sure the custom field is added to the View ISsue screen, and then look at the field value in the issue screen (the issue navigator is based on the Index, which will need to be rebuilt once your formula works).

David,

The second formula above works for me, as I am calculating the total time between a ticket Created and Resolved. However, it looks like it gets returned as an integer. Is there any any way to return as a decimal (for example, a ticket under 24 hours is all getting returned as "0" )

 

Thanks,
Geoff 

&lt;!-- @@Formula: issue.get("resolutiondate")==null ? null : ((Double)(issue.get("resolutiondate").getTime() - issue.get("created").getTime())) / 1000 / 3600 / 24 --&gt;

Thanks a lot! That seems to work great.

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 Sunday in Agility

You asked for it, so we delivered: images on issues have arrived

A picture tells a thousand words. And agility boards have just released their latest feature: cover images on issues – so now your board can tell a story at first glance. Upload attachmen...

149 views 1 10
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