It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

Alex Wilson Feb 09, 2016

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

1 vote
Nicolas Bourdages Feb 09, 2016

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. 

Alex Wilson Feb 09, 2016

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!

1 vote
Udo Brand Feb 09, 2016

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.

 

 

Alex Wilson Feb 09, 2016

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

Udo Brand Feb 09, 2016

 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
Alex Wilson Feb 09, 2016

@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.

0 votes
Rahul Aich [Nagra] Feb 09, 2016

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

That should solve your issue.

Rahul

Alex Wilson Feb 09, 2016

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
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Posted in Jira Core

How to manage many similar workflows?

I have multiple projects that use variations of the same base workflow. The variations depend on the requirements of the project or issue type. The variations mostly come in the form of new statuses ...

760 views 7 0
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you