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 to set a sub task due date depending on current date?

Hi, 

I have a script that create 3 sub tasks that user set MW Date...

def subTask1 = SubTask.createSubTask(issue, "Prepare Testbed", "SPB", "O&M task", dtMWDate-7, dtStartDate, null, userOm)

def subTask2 = SubTask.createSubTask(issue, "Generate MOP", "SPB", "O&M task", dtMWDate-7, dtStartDate, null, userOm)

def subTask3 = SubTask.createSubTask(issue, "Execute Maintenance Window", "SPB", "O&M task", dtMWDate, dtStartDate, dtMWDate, userOm)
SubTask.setLabel(subTask6, "MW")

The sub task 1 and 2 it calculate due date based on MW Date (Sub task3), the problem is when someone create this issue with the MW date for TODAY or less than 7 days, so my sub task 1 and 2 will be create with due date in the past. I would like to know how can I add on my script a fuction that everytime my MW DATE is for TODAY or less than 7 days, the due date for sub task 1 and 2 automatically is set to current date.

Thank you!

1 answer

Hi Artur,

 

You can use something similar to this to check if the date is less that 7 days before or after today's date: 

Date date = new Date()
if(issue.dueDate <= date + (7) )
{
  // set issue's MW due date to 'date' here
    
}

Let me know if that works.

Thanks,

Johnson Howard

When you said "set issue's MW due date to 'date' here" you mean to set current date? But what is the function to do it?

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published Apr 09, 2019 in Portfolio for Jira

Portfolio for Jira 3.0 is here!

The wait is over... Portfolio for Jira Server and Data Center 3.0 is now officially here! Platform releases offer Atlassian an opportunity to shift our strategy, make bold predictions about t...

1,566 views 14 26
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you