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

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 automatically update the End Date of the parent issue?

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?

1 answer

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) {
issueManager.updateIssue(event.user, parentIssue, EventDispatchOption.ISSUE_UPDATED, false)



Suggest an answer

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

Admins, notify your Jira instance of system-wide changes with the new admin announcement banner

Hi All! We’re excited to share the launch of an announcement banner that lets Jira site administrators communicate directly to their users across their  Jira Cloud instance.  ...

772 views 17 21
Read article

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