Using Due Date for Automation
Asked by Nick Brotherton:

I am try to write an automation to update epic Due Dates. It seems like every combination of writing Due Date in the lookup issues function does not work. I've tried:

{{lookupIssues.first.Due Date}}

{{lookupIssues.first.Duedate}}

{{lookupIssues.first.DueDate}}

{{lookupIssues.first.duedate}}

{{lookupIssues.first.due date}}

Nothing works! Below is a link of what I'm attempting to replicate. At the end, someone mentions the solution is to use Duedate but that does not work for me. I'm on Cloud, very much at a loss..

<https://community.atlassian.com/t5/Jira-Cloud-Admins-discussions/Set-Epic-Start-and-Due-Date-to-earliest-latest-Child-Dates/td-p/2353100>


Answers:
author: Bill Sheboy
body: Hi [@Nick Brotherton](/t5/user/viewprofilepage/user-id/5591383) -- Welcome to the Atlassian Community!

For a question like this, please post an image of your complete automation rule, images of any relevant actions / conditions / branches, an image of the audit log details showing the rule execution, and explain what is not working as expected. Those will provide context for the community to offer ideas. Thanks!

Until we see those...

The correct smart value for the Due Date field is {{issue.duedate}} or this expression for the *first issue* in a Lookup Issues result: {{lookupIssues.first.duedate}} And you may identify the correct smart values for a field using this how-to article: <https://support.atlassian.com/cloud-automation/docs/find-the-smart-value-for-a-field/>

But that does not seem like what you wanted...

If you want the earliest value that would be {{lookupIssues.duedate.min}} or the latest value would be {{lookupIssues.duedate.max}}

What value do you want in the Epic, based upon its child issues?

Kind regards,  
Bill

comments: author: Nick Brotherton
body: It's essentially exactly what is mentioned in the link.. if I use min/max, is there a better usecase for the lookup issue? Here is the automation. I'll also try put the duedate as lower case ![Screenshot 2024-09-13 091003.png](https://community.atlassian.com/t5/image/serverpage/image-id/347354i2AF968F4FDC54D63/image-size/large?v=v2&px=999 "Screenshot 2024-09-13 091003.png")


author: Nick Brotherton
body: Also thanks for your help and speedy reply!


author: Bill Sheboy
body: Thanks for that information, Nick.

*What do you want the rule to do with the Epic's date fields when there are no values found in the child issues? For example, should it clear the date, leave it as is, or something else?*

Regarding min / max, for your scenario you are apparently trying to find the earliest Start Date and the latest Due Date. Is that correct?

If so and we assume there is at least one issue with a non-empty Start Date and Due date, you only need to use one Lookup Issues action:

```
the earliest Start Date would be this: {{lookupIssues.Start date.min}}

the latest Due Date would be this: {{lookupIssues.duedate.max}}
```

Also please note: the way your rule is written, **the processing will stop when a condition is not met**. And so if there are no issues found with a non-empty Start Date, logic for setting the Due Date will not happen.

The if / else condition normally helps for such scenarios, but your rule is branching to the parent and that type of condition is not possible inside a branch. There are two possible solutions: split this into two rules or use the if / else conditions first with a branch inside.

I recommend splitting this into two rules to handle the different cases, subject to the answer to how to handle empty date fields. Then your original rule could mostly remain unchanged.

* trigger: field value changes for Start Date
* condition: issue type is not Epic
* branch: to parent
  * action: lookup issues to get all children of the epic with
    * parent = {{issue.key}} AND "Start date" IS NOT EMPTY
  * smart value condition: check if {{lookupIssues.size}} is greater than 0
  * action: edit issue to set the field, as needed

Test that rule, then clone the rule to make one for the Due Date field.


Tags: cloud

jira-cloud