Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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?

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.

@alexlwilson  It has been quite a long time, but we are currently trying to do something similar and I would like to know what worked better for you. Thanks!

@Noa Diaz 

In the end, we accomplished this by using Automate Lite for Jira (now owned by Atlassian and built into Jira Cloud) to reopen the tickets every day at 12am and created a post-function during that transition to increment the due date field based on a dropdown field on the ticket that assigned the frequency  (Week, Month, etc.). We used the Jira Workflow Toolbox plugin and created the below setting using the "Update parameters of the Set a field as a function of other fields Function for this transition" post-function:

 

(Weekly){00012} + {WEEK}
(Bi-weekly){00012} + 2 * {WEEK}
(Monthly){00012} + {MONTH}
(Quarterly){00012} + 4 * {MONTH}
(Semi-annually){00012} + 6 * {MONTH}
(Annually){00012} + 12 * {MONTH}

Suggest an answer

Log in or Sign up to answer
TAGS
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 ...

4,562 views 12 8
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