When an existing Epic's due date changes I want to calculate the difference in business days between the old value and the new value, and then apply that difference, also in business days, to the due date of each child ticket. Most of the child tickets will have a due date that can be anywhere from 1 to 60 days prior to the Epic's due date, so if the Epic's due date changes it can be a pain to manually recalculate the new due date for each of its child tickets.
I've been able to accomplish the first part using 3 sequential variable actions to get the Epic's old due date value, new due date value, and diff in business days. However, when I try to modify the child tickets' due date using the output from the 3rd variable as the number of business days the end result is that each child's due date field gets cleared.
Here's an example of the rule I've got built as a proof of concept. It intentionally assumes that the Epic's new due date will always be greater than its old due date to make for easier troubleshooting:
When: value changes for Due date
If: issue type = Epic
Then: create variable
- variable name: varEpicOldDueDate
- smart value: {{#changelog.duedate}}{{fromString}}{{/}}
And: create variable
- variable name: varEpicNewDueDate
- smart value: {{issue.duedate}}
And: create variable
- variable name: varEpicDueDateDiff
- smart value: {{varEpicOldDueDate.toDate.diff(varEpicNewDueDate.toDate).businessDays}}
Branch: for children
- If: Due date is not empty
- Then: edit work item fields
- Due date: {{issue.duedate.plusBusinessDays(varEpicDueDateDiff)}}
