Setting due dates on subtasks using .minusBusinessDays(x)

Rick Crow
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 2, 2020

I'm attempting to create an automation that sets due dates for each of an issue's subtasks by referencing the due date (or other custom date field) in the parent task and a date 'offset' value from a custom number field in each subtask. Our use case is that such a task/subtask scenario could be used as a template for subsequent task/subtask instances and the due date of each subtask could then be updated by simply updating the single due date in the parent task.

My thinking was that I would use something like this:

{{#=}}{{issue.parent.duedate}} - {{issue.Visit date offset}}{{/}} 

but this throws errors and obviously I'm missing the point.

I'm no coder, and that's likely clear to anyone that is, so bear with me as I explore automation options. Any help is appreciated!

3 answers

1 accepted

1 vote
Answer accepted
John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 2, 2020

Hi Rick,

I think you will need to use the Diff date feature to get a number first - and save that to custom field. I would do that one one (or either) of the dates is updated.

Then you can use the proper code to set the date. Something like: 

{{triggerIssue.duedate.minusDays(5)}}

Rick Crow
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 2, 2020

John, thanks for the response. I'm not sure your thought captures what I'm trying to accomplish. Each subtask will already have a value to use to subtract from the parent task due date, so I'm not sure what using diff date will accomplish. My question ... either with your proposed approach or mine, is, once I have the offset value, how do I use it to set the subtask date?

John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 2, 2020

So the offset field is a number field? I missed that, sorry. 

I don't think you are going to be able to dynamically use the value of the field with the current smart values syntax. You need to use the code I have above, but I don't see a way to make the "5" in my example an actually field. 

@John McKiernan1  - Any thoughts on that? Rick would like to use this:

{{triggerIssue.duedate.minusDays(5)}}

but instead of having a hardcoded 5, it would be the value in a custom field. 

BTW, that would be REALLY cool!!

Rick Crow
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 2, 2020

Thanks again, John. Yes, that's what I'm looking for. Without such an approach, the automation development would seem to be unnecessarily complex. I.e., having to have a unique condition, action, etc., for each step in a multi-step process ... or more specifically, for each subtask within its parent task. That's doable given we're basically building a mini-project template that shouldn't change often, but still less than ideal.

Rick Crow
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 3, 2020

@John McKiernan1 @[deleted] : Any hope for me and my use case?

John McKiernan
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 3, 2020

Hey @Rick Crow ,

To be honest, I am not sure but I have asked an engineer who will know and will answer you here :) 

John

Simmo
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 3, 2020

Hey chaps,

So, you should just be able to reference the field in the minus part, eg:

 

{{triggerIssue.duedate.minusDays(issue.Custom Number Field)}}
Let me know if that doesn't work for you, it should.
Cheers,
Simeon
[Automation for Jira - Dev]
Like # people like this
John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 4, 2020

@Simmo  - Holy Cow! If that works, I now owe you TWO beers whenever I meet you!!

Like Simmo likes this
Rick Crow
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 4, 2020

Looks like you owe him TWO beers now then, John ... as it works!

Which is awesome, but also kind of frustrating as, with one of my attempts, all I would have had to do was remove the extra curly braces I had used within the 'minus part.'

Thanks, Simeon and John ... you've made my day!

John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 4, 2020

Made mine, too! Thanks for testing that out. 

Will be the best two beers I have bought in my life  ;-)

Rick Crow
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 4, 2020

@John Funk , @Simmo : while I have your attention, could I possibly direct you to another question I've raised regarding automation? Any thoughts would be greatly appreciated!

https://community.atlassian.com/t5/Jira-Software-questions/Automation-Subtask-clone-action-results-in-reverse-order/qaq-p/1394297

Simmo
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 4, 2020

No worries guys, glad it worked :D

Unfortunately, its got to be Gluten Free Beer now, that lessens my chances! :D

Like John Funk likes this
0 votes
John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 16, 2020

Hey Morten - Not exactly sure what you are trying to accomplish. 

If you do an Edit issue then cite the Due Date field, your code will definitely replace the Due Date with a new value. 

What do you mean by "I just want a simple way of trioggering an offset/postpone of the due date field."? Can you give us an exact scenario?

Morten Stensgaard October 19, 2020

Hi John.

 

I just want to trigger an event/transition which takes the original Due Date and offesets it with a numeric value(+ 30 days) - A re-occuring event based on issue data.

 

So basically this Automation scenario:

When Due Date < Now

Then: Due Date = Due date + customfield(numeric)

 

I cannot get this to work with Automation when trying to update the Due Date field with:

{{triggerIssue.duedate.plusDays(issue.customfield_20530)}} 

 

Result: It just blanks the field

If I used a fixed value ex. 30 as input in smart value func, it works just fine - But I want the input to be flexible from a custom field.

kfarnen December 2, 2020

@Morten Stensgaard did your question get answered? I'm trying to accomplish something really similar.

Kelley Mills May 6, 2021

How would I use this when "duedate" is a custom field. Would I write this as {{trigger.issue.issue.customfield_#####.minusDays(#)}}?

0 votes
Morten Stensgaard October 16, 2020

@Simmo 

Hi Simeon.

 

I have a similar. usecase, where I just need to offset the duedate by x days(numeric value from a custom field)

 

But then trying this in an Update field - action on the Due date field it just removes the existing date.

I'm using this in the Action of the update of Due Date:

{{triggerIssue.duedate.plusDays(issue.customfield_20530)}}

Custom fields contains the value 30

 

I just want a simple way of trioggering an offset/postpone of the due date field.

 

Thanks

Morten

Suggest an answer

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

Atlassian Community Events