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 -->
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 must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Awesome! Works perfectly now! Thanks a lot David!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
<!-- @@Formula: issue.get("resolutiondate")==null ? null : ((Double)(issue.get("resolutiondate").getTime() - issue.get("created").getTime())) / 1000 / 3600 / 24 -->
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Error seen on logs are CalculatedDateField: formula does did return a Date object:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.