Calculating Calendar Days Between Issue Creation and Resolution Using Script-Runner: A How-To Guide

adminUncategorized

Are you using Atlassian JIRA as tool to track customer complaints and suggestions. Do you want to improve your support operation then you know that numbers will tell you the tale.  How long does it take to pick up an issue, what is the average resolution time.  Atlassian is providing a great product to manage the complete support cycles, but at a price.   This blog is about an alternative which is based on the Script Runner for JIRA which allows you to create calculated fields through a simple groovy script.
Steps

  • Install the script runner from the marketplace
  • Create a custom field of type scripted field, name it ‘Time to resolve’ and attach it to the right screens

image2016-3-30-15_11_16

  • Access the scripted fields section of the add-on

image2016-3-30-15_14_12

  • Edit the newly created field and add following script to calculate the number of days between the creation and the resolution
def createDate = issue.getCreated();
def resolutionDate = issue.getResolutionDate();
if (resolutionDate == null) {
   return null;
}
return resolutionDate - createDate;
  • make sure that the template is set to number

image2016-3-30-22_30_3

  • Save the configuration and you’re done.
  • Have a chocolate

Further reading

The script runner has endless possibilities to customise your JIRA to your operating environment. Want to know more, don’t hesitate to attend the ‘automate your processes with JIRA’ event on April 14.

The documentation site of the script runner has more elaborated examples to calculate the time an issue has been in a particular status –

https://scriptrunner.adaptavist.com/latest/jira/scripted-fields.html