Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to automatically change start and due date of subtasks

Umar Maroof
Contributor
January 4, 2023

Hi

Hope everyone doing well

In my project I have task under these tasks the subtasks are created automatically where start dates and due dates of subtasks are also created automatically by setting the value of the fields in automation

Now for example I created the task

Subtask 1 (start date 2 jan , due date 4 jan)

subtask 2 (start date 3 jan , due date 5 jan)

and so, on 

there are so many subtasks like this where start and due dates are automatically generated

Now what I want if change the due date for any of the subtask the remaining subtasks start date and due date automatically change.

I am not sure how to achieve this

I am using jira cloud 

 

3 answers

1 accepted

0 votes
Answer accepted
Alex Koxaras -Relational-
Community Champion
January 4, 2023

Hi @Umar Maroof 

This requirement of your was a nice exercise for me! It was a bit tricky to accomplish that, but everything turns out great! You can create the following rule which I'll explain just below:

When the Due date for a task issue type is changed, then Start Date and Due Date of all subtasks to that task will be increased or decreased by the same amount of difference between the new and the old task's due date.

rule001.png

 

  • Starting off, you create your trigger to which you select "Due date" and only for the edit operation.
  • Next you should add a condition about this rule continuing only if the issue type is task (you don't want this to get triggered for Epic or subtasks)
  • Then you create a variable called "difference" or whatever else you choose and in that you type the below smart value, which will give you the difference number of days for the changed field.
{{fieldChange.fromString.toDate.diff(fieldChange.toString.toDate).days}}

rule002.png

 

  • After that you create your branch and you choose "For Sub-tasks"
  • Then you add an Edit Issue component and you select your two fields, Start and Due date
  • Then you paste as a value the following:
    • {{issue.Start date.plusDays(difference.asNumber)}}
    • {{issue.Due date.plusDays(difference.asNumber)}}

rule003.png

 

Some things to take into account:

  • If the subtasks have values but your task does not, then changing the values from the task, will erase the values from your subtask. So be careful with that
  • Take a look at that @Tessa Tuteleers wrote about the business days. Increasing or decreasing days without taking into account weekends, can result in having a Start or Due date falling into a weekend. To avoid that try on the Edit Issue component to replace plusDays with plusBusinessDays

Let me know if that works for you.

Umar Maroof
Contributor
January 4, 2023

@Alex Koxaras -Relational- 

Thanks for your time 

I did this automation

But when I cahnges the due date for tasks the subtasks start date and due date will become 0 

Alex Koxaras -Relational-
Community Champion
January 4, 2023

Double check that the values you enter on edit issue component are correct. E.g. issue.Start date is different that issue.startdate. This will result in entering a null value => 0.

Umar Maroof
Contributor
January 4, 2023

Great its work fine now

Thank you so much for your help......!

Alex Koxaras -Relational-
Community Champion
January 4, 2023

Kindly mark my answer as accepted in order to help others! Thank you!

Like Umar Maroof likes this
Umar Maroof
Contributor
January 4, 2023

@Alex Koxaras -Relational-  I have one more question regarding to this automation 

can we did this for link issues for example I have 3 subtasks 

subtask 1 

subtask 2 

subtask 3

Subtask 2 and 3 are blocked by subtask 1

Now same like this automation when we change the due date for subtask 1 the start and due date of subtask 2 and 3 will change 

can we achive this?

Alex Koxaras -Relational-
Community Champion
January 4, 2023

@Umar Maroof you don't have all the requirements for this change yet. You could perhaps achieve this by creating another rule, but it's not that simple.

From the basic rule, if you change the due date, then it will change the dates for all subtasks below (namely 1,2 and 3). Then the new rule will be triggered and change again subtasks 2 and 3, because subtask 1 was changed...

Umar Maroof
Contributor
January 4, 2023

@Alex Koxaras -Relational- I want to do the second part sperately Like I just want to change the  subtask 1 due date and it will change the start due dates for his link issues (that are blocked by subtask 1 i.e 2 and 3)

Anna Bartczak December 13, 2023

Hello @Alex Koxaras -Relational- 

I used the Automation rule shared here - thank you. 

For the "Start date" the automation did not work (updated "Start date" to empty value) when User was using Jira in language different than English (in English automation rule worked fine).

I got suggestion from support to change how the difference variable is calculated to:

{{fieldChange.from.toDate.diff(fieldChange.to.toDate).businessDays}}

Use "from" instead of "fromString" and "to" instead of "toString" the format conversion probably caused the problem.

Anna

Mateusz Slifirczyk
Contributor
January 10, 2024

@Anna I'm getting empty values for both Start and Due dates when using the automation so was looking into using your version of the variable. Where did you put start and due date within that code, does it replace fieldChange?

1 vote
Tessa Tuteleers
Community Champion
January 4, 2023

Hi @Umar Maroof , 

best wishes! 

You could use Automation for that as well, but the most important part is figuring out your logic first (if the date of an issue changes, how do the other dates need to behave?)

For an easy example, let's just say that you need the other issues to add a few days to the date you just set yourself. 

  • Your trigger would be a field value change (for the start or duedate)
  • You would need to branch your rule to find the sibling sub-tasks of the sub-task you just edited. A JQL would be fine for this: 
    parent = {{triggerIssue.parent.key}}
    This finds all other subtasks of the same parent. You might want to add a resolution condition or some other things too.
  • Then you need to apply your logic to the new date fields. 
    Something like 
    {{triggerIssue.duedate.plusBusinessDays(5)}}
    gets the new date of the issue you changed and then adds some days, but you can get more advanced logic involved like calculating diffs, date logic is described pretty good here.

Hope this helps! 

- Tessa

0 votes
Sebastian Krzewiński
Community Champion
January 4, 2023

Hi @Umar Maroof 

 

You can also use for this automation and smart values. Please take  a look on https://support.atlassian.com/cloud-automation/docs/examples-of-using-smart-values-with-dates/#Manipulating-dates

 

Regards,

Seba

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events