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

Automatically Set sub-task due date to be 5 days before Parent due date

I need to be able to set the due date of Sub-tasks based on the Due date of the Parent. Ideally this needs to be 5 working days before. I currently have the code below which sets the due date on the parent to be 30 days after the date entered in Custom field "Received Date". I have been trying to reuse it for the sub task date auto set mentioned above but I'm not having any luck! Any ideas would be greatly appreciated!


import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.UpdateIssueRequest
import java.sql.Timestamp;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.event.type.EventDispatchOption

int days = 30;

Calendar dueDate = Calendar.getInstance();
dueDate.setTime( (Date) issue.getCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Received Date")));

while (days != 0)
    dueDate.add(Calendar.DAY_OF_YEAR, 1);
    if((dueDate.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY) || (dueDate.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY))

issue.setDueDate (new Timestamp (dueDate.getTime().getTime()));

0 answers

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

551 views 15 18
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