Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Problem

Sometimes a task is not really complete and needs to be followed up on at a later time. Leaving the issue open as reminder can create a mess on reports and in backlogs and does not necessarily work effectively.

Solution

A solution would be to close the ticket with some added information. For example, a transition screen can be added where the user can enter a date or a time period that should indicate when the issue should be reopened.

Writing the code

The following script will reopen the issue on a specified date.

Code Block
languagejava
//the transition id's are needed by the autoTransition() routine
string [] transitionIds;
transitionIds["Bug"] = "11";
transitionIds["Task"] = "21";
transitionIds["Story"] = "31";

for(string pkey in argv) {
    //the following JQL query is responsible for selecting the issues that are ready to be reopened
    string JQL = "project = " + pkey + " AND type in (Bug, Task, Story) AND statusCategory = Done AND \"Reopen Date\" <= startOfDay()";
    
    //select issues using JQL and loop through them
    for(string i in selectIssues(JQL, 500)) {
        autotransition(transitionIds[i.type], i); //reopen the issue
        addComment(i, currentUser(), "This issue has been automagically reopened because it has reached the reopen date previouslly assigned."); //add comment explaining why the issue was reopened
        %i%.priority = "High"; //increase the priority assuming it is not already high
    }
}

The above script can also be modified to work with an interval. So, instead of the user specifying that the issue should be reopened on November 12th, the user could tell the script to reopen in 90 days. In this case, a custom field would be used and the user would enter an interval value similar to tracking time. So the user would enter ā€œ90dā€ to represent 90 days.

Code Block
//the transition id's are needed by the autoTransition() routine
string [] transitionIds;
transitionIds["Bug"] = "11";
transitionIds["Task"] = "21";
transitionIds["Story"] = "31";

for(string pkey in argv) {
    //the following JQL query is responsible for selecting the issues that are ready to be reopened
    string JQL = "project = " + pkey + " AND type in (Bug, Task, Story) AND statusCategory = Done AND \"Reopen After Period\" is not EMPTY";

    //select issues using JQL and loop through them
    for(string i in selectIssues(JQL, 500)) {
        //calculate the reopen date
        date reopenDate = i.resolutionDate + i.reopenPeriod;
        if(currentDate <= reopenDate) {
            autotransition(transitionIds[i.type], i); //reopen the issue
            addComment(i, currentUser(), "This issue has been automagically reopened because it has reached the reopen date previouslly assigned."); //add comment explaining why the issue was reopened
            %i%.priority = "High"; //increase the priority assuming it is not already high
        }
    }
}

Will this wrk

Table of Contents

Table of Contents