How do I set JIRA up to re-open a task and change the due date automatically?

I'm in the process of making a project that will track all of our maintenance requests and TPM for our shop floor. For TPM, Total Preventative Maintenance, we have set tasks that need to be done every month, quarterly, semi-annual, or annually. 

What I would like to do is have JIRA automatically  re-open (re-schedule) a task once maintenance has marked it as complete. It would then need to change the due date based on the previous due date, or when it was completed (one or the other, we wouldn't use both methods at the same time). 

Are there any plugins that can already do this? If not, any ideas on how I could accomplish it?

3 answers

There's the Scheduler plugin that does something similar to that. It doesn't reopen the same task, because that wouldn't be trackable as metrics, but it creates new ones on scheduled dates.

If you would rather have the re-scheduling done not on fixed dates, but in relation to the time the issue was moved to the Done status for instance, then you need to do some post-function voodoo with the help of scripts or some plugin(s). Issue Templates would let you set a special post-function that would create an issue in the transition to Done.

But if it was for me, i'd get the scheduler plugin solution. It's reasonably priced and sounds like a good thing to have in other JIRA processes as well. 

I had looked at that one briefly, but I'll give it another try. I'm not well versed on creating "complex" scripts, so I'd like to stay away from them for now.

Thanks for the suggestion!

I used Scriptrunner plugin for a similar requirement:automatically create repeating task/subtask depending on a frequency (monthly, quarterly, etc.) and setting due dates accordingly.

Basically we used the escalation service to transition issue through a transition with some scripted postfunctions where all the logic (create subtask, calculate due date) was taking place.

I had not much experience in scripting as well, but got some help by colleagues and examples posted in this forum.

 

 

Do you have any links, or can you share the script that you run in the post-function?

 That is the script we use in Create Subtask postfunction. It does some additional things as well.

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.customfields.CustomFieldType
import com.atlassian.jira.issue.fields.CustomField
import java.sql.Timestamp;
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
calendar.setLenient(false);
Calendar calendarP = Calendar.getInstance();
calendarP.setTimeInMillis(System.currentTimeMillis());
calendarP.setLenient(false);
def Integer days = 0
def Integer daysP = 0
if(cfValues['Frequency']*.value.contains("Weekly")){
    days = 3
    daysP =6 }
if(cfValues['Frequency']*.value.contains("Biweekly")){
    days = 7
    daysP =13 }
if(cfValues['Frequency']*.value.contains("Monthly")){
    days = 15
    daysP =30 }
if(cfValues['Frequency']*.value.contains("Quarterly")){
    days = 61
    daysP =91}
if(cfValues['Frequency']*.value.contains("Semi-annually")){
    days = 121
    daysP =181}
if(cfValues['Frequency']*.value.contains("Annually")){
    days = 275
    daysP =365}
if(cfValues['Frequency']*.value.contains("Biannually")){
    days = 550
    daysP =730}
if(cfValues['Frequency']*.value.contains("Triannually")){
    days = 915
    daysP =1095}
    
calendar.add(Calendar.DAY_OF_MONTH, days);
calendarP.add(Calendar.DAY_OF_MONTH, daysP);
Timestamp mydueDate = new Timestamp(calendar.getTimeInMillis());
Timestamp myPDate = new Timestamp(calendarP.getTimeInMillis());
def eid = customFieldManager.getCustomFieldObjects(issue).
    find {it.name == 'External issue ID'}
def ped = customFieldManager.getCustomFieldObjects(issue).
    find {it.name == 'Planned End Date'}
def psd = customFieldManager.getCustomFieldObjects(issue).
    find {it.name == 'Planned Start Date'}
issue.setCustomFieldValue(ped, myPDate)
transientVars["issue"].setCustomFieldValue(ped, myPDate)
//allow no links to be copied to subtask
checkLink = {link -> false};
    
//set external issue id to null on subtask
issue.setCustomFieldValue(eid, null)
issue.setDueDate(mydueDate);
transientVars["issue"].setDueDate(mydueDate);
issue.setCustomFieldValue(psd, mydueDate)
transientVars["issue"].setCustomFieldValue(psd, mydueDate)
issue.summary =  myPDate.format("MM.yyyy")+ ': ' +  
    transientVars["issue"].summary

@Udo Brand,

Awesome! Thanks for posting it!

I'm going to try the Scheduler plugin first, but will go your route if that doesn't fit our needs.

Why dont you update your workflow so that when maintenance completes the task, the destination step becomes Open.

That should solve your issue.

Rahul

How would I have it change the due date automatically? There are too many tasks to have someone manually edit the due date every time.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Monday in Jira Ops

Jira Ops Early Access Program Update #1: Announcing our next feature and a new integration

Thanks for signing up for Jira Ops! I’m Matt Ryall, leader for the Jira Ops product team at Atlassian. Since this is a brand new product, we’ll be delivering improvements quickly and sharing updates...

454 views 0 9
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