Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×I have a need for a script that can return the difference in dates between the date an issue was due and the date it was resolved (the idea is to provide a measurement for delivery precision).
I have tried something like this:
def dueDate = issue.getDueDate();
def resolutionDate = issue.getResolutionDate();
if (resolutionDate == null) {
return null;
}
return resolutionDate - dueDate;
The problem is that the (resolutionDate == null) gives an error since there apparently is a problem with the equals operator and the ingoing types of operands.
Yet, the code shows what I am trying to accomplish and I have tried different implementations but they all tend to generate a nullPointerException. The problem is that this is all there is in the log or the preview so I am stumbling in the dark.
Please, does anyone know how to accomplish this?
Probably duedate is empty then, so lets check both due date and resolution date for null.
This works for me:
def dueDate = issue.getDueDate();
def resolutionDate = issue.getResolutionDate();
if (resolutionDate && dueDate) {
return resolutionDate - dueDate;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Karl!
Also there is a free of charge plugin - JIRA Misc Custom Fields
which allow to set calculated date fields. I have not tried it for now, but maybe it can help.
Regards
Vyacheslav
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Have you tried this?
def dueDate = issue.getDueDate();
def resolutionDate = issue.getResolutionDate();
if (resolutionDate) {
return resolutionDate - dueDate;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tried this but I get java.lang.NullPointerException: Cannot invoke method minus() on null object
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Karl,
The solution provided above by Filip is what you need to use ensuring you run this code as a scripted field on the issue.
I have attached a sample of how you can set this code as a scripted field in order to achieve your requirements.
Screen Shot 2016-08-19 at 16.05.05.png
I hope this helps.
Thanks
Kristian
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.