Forums

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

Set subtask due dates based on variable offset custom field value

Jeff Xanthos
Contributor
June 1, 2024

Hi, 

I've got a parent task and a bunch of sub tasks. The parent task has a custom field 'Open Date'. This is set at the parent and an automation sets the same value through all sub tasks.

I have added a custom field to the sub tasks, it is called 'Offest', the value can be -10, 0, 1, 2 or 2+

For each Offset value, I want to set the due date, kind of like this:

WHEN Offset is 0 THEN {{issue.parent.Open Date}}
WHEN Offset = 1 THEN {{issue.created.plusBusinessDays(20)}}
WHEN Offset = 2 THEN {{issue.created.plusBusinessDays(50)}}
ELSE {{issue.parent.Open Date.minusDays(issue.Offest)}}

I couldn't get nested if / else to occur after branch level, and created a condition for each.

See screenshot of rule, its seems convoluted.auto-jira.png

3 answers

1 accepted

1 vote
Answer accepted
Jeff Xanthos
Contributor
June 1, 2024

I simplified it in the end, using the custom field ID's ending up with a successful run.

The simplification was introducing another offest, for only two conditions.

This worked WHERE either offset is empty, I replaced the custom field names with their ID's

{{triggerIssue.parent.Open Date.minusDays(issue.OpenOffset)}}
{{triggerissue.created.plusDays(issue.StartOffest)}}

0 votes
Walter Buggenhout
Community Champion
June 1, 2024

Hi @Jeff Xanthos and welcome to the Community!

Have you considered filling out the exact number of days you would like to add as your offset field on the subtasks, trying to use the same calculation once for all your subtasks, making it dynamic?

issue.created.plusBusinessDays({{Offset}})

If you somehow feel you need to use conditions, you may also consider defining a lookup table that helps you translate the conditional values into the number of days you want to add, thus creating more or less the same effect: based on your logic, you figure out the number of days you need to add to your calculation and then execute it once with the dynamically retrieved number of days.

Hope this helps!

Jeff Xanthos
Contributor
June 1, 2024

Thanks Walter
{{issue.parent.Open Date}} can change through out the course of the project. So we have a number of sub tasks that are due on {{issue.parent.Open Date}}, others due X days after {{issue.parent.created}} and others are due X days before {{issue.parent.Open Date}}. 

I haven't explored lookup tables yet I'll take a look.

0 votes
Jack Brickey
Community Champion
June 1, 2024

Hi @Jeff Xanthos ,

What issue did you run into with if/else? I also wonder if you could simply express the offset as the number of days rather than having to 'decode' thus. That is use "-10", "20", etc. that would simply your rule by eliminating the if/else condition.

Jeff Xanthos
Contributor
June 1, 2024

Hi @Jack Brickey 
No if / else technically, that condition cant be loaded it seems after introducing the sub task branch, I did see you could use JQL at branch level to get around that but continue with multiple if's just to see if I could get the logic conditions working first.

Expressing the offset as the number of days I have done, but I am multi purposing the use of that field ( SQL case statements are something Im used to working with) to come up:

WHEN Offset is 0 THEN {{issue.parent.Open Date}}
WHEN Offset = 1 THEN {{issue.created.plusBusinessDays(20)}}
WHEN Offset = 2 THEN {{issue.created.plusBusinessDays(50)}}
ELSE {{issue.parent.Open Date.minusDays(issue.Offest)}}

Maybe creating a custom field (offset) for both the OpenDate and CreatedDate is the way to go. 

Here's the list of subtasks and the respective columns, only the first condition Offset is 0 THEN {{issue.parent.Open Date}} worked.
jira list.png

And this is the audit log result
audit.png

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
atlassian, atlassian community, loom ai, atlassian loom ai, loom, atlassian ai, record recaps of meetings, meeting recaps, loom recaps, share meeting recaps,

Loom’s guide to great meetings 📹

Join us to learn how your team can stay fully engaged in meetings without worrying about writing everything down. Dive into Loom's newest feature, Loom AI for meetings, which automatically takes notes and tracks action items.

Register today!
AUG Leaders

Atlassian Community Events