You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
I have downloaded both ScriptRunner and Automation for Jira as I am trying to automatically update the end date of a story, if its subtask has an end date exceeding its own.
For example, I have created a story which will run from 1st January to 20th January. Within this story, I have created a subtask which runs from 10th January to 18th January. Now if the subtask overruns and I increase the end date to 24th January, I want the story to automatically update to have an end date of 24th January, as opposed to its original end date of 20th January.
Does anyone know how to do this?
If you set up a Custom Script Listener that fires on the Issue Updated event, you can write a script like this that will monitor the Due Date field for the Sub-tasks. If the Due Date of the sub-task gets updated and is greater than the Due Date of the parent Story, it will update the Story's Due Date to match the sub-task.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.event.type.EventDispatchOption
def issue = event.issue
def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()
def issueManager = ComponentAccessor.issueManager
//Get last changed item
def lastChangedItem = changeHistoryManager.getAllChangeItems(issue)[-1] // looks at end of list
if (issue.getIssueType().name == "Sub-task") {
def parentIssue = issue.parentObject as MutableIssue
if(lastChangedItem.field == "duedate") {
log.debug("Sub-task due date was updated!")
if (issue.dueDate > issue.parentObject.dueDate) {
parentIssue.setDueDate(issue.dueDate)
issueManager.updateIssue(event.user, parentIssue, EventDispatchOption.ISSUE_UPDATED, false)
}
}
}
Regards,
Josh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.