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?
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Why dont you update your workflow so that when maintenance completes the task, the destination step becomes Open.
That should solve your issue.
Rahul
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.