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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,554,909
Community Members
 
Community Events
184
Community Groups

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!

Thanks!

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))
        continue;
    
    --days;
}


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

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events