Forums

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

How to pick up earliest date from Child and copy to Parent

Sinisa Glusac
Contributor
December 16, 2022

I'm trying to make automation that will choose earliest date from child ticket (start date field) and copy it to Parent ticket start date. 

For instance Parent “Start Date“ = 01.02.2020, Child “Start Date“ = 01.01.2020, Child “Start Date“ = 01.03.2020 → Parent  “Start Date“ = 01.01.2020. 

I've created automation that collecting date from Child and adding to Parent, but it collect just any date,  now it needs to be earliest date. 

If anyone knows some JSON formula or Smart value and wants to share, that would be appreciated. Thank you in advance. 

Current automation looks like this:

Screenshot 2022-12-16 135255.png

2 answers

1 accepted

1 vote
Answer accepted
Bill Sheboy
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.
December 16, 2022

Hi @Sinisa Glusac 

To confirm the problem you are trying to solve...you only want the Parent to change to the earlier date if a Child issue has one.  Is that correct?

If so, couldn't you change your advanced compare condition in the branch to:

  • first value: {{triggerIssue.Start date}}
  • condition: less than
  • second value: {{issue.Start date}}

If instead you need the earliest date among all child issues, consider using Lookup Issues instead with JQL.  That will handle the case of an issue changing parent when the dates do not change...and that may required a couple of rules with different triggers: field value changed for Start Date, and issue updated for a change in parent (both the incoming and outgoing parents could need updates).

Kind regards,
Bill

Sinisa Glusac
Contributor
December 16, 2022

Hi @Bill Sheboy yes, this is correct, and I tried your solution, it works perfectly. Thank you very much for your help and also thanks to Jack for his suggestion!

Like Bill Sheboy likes this
Santosh Subramani October 10, 2023

Hello @Sinisa Glusac 

 

Can you post the automation script 

1 vote
Jack Brickey
Community Champion
December 16, 2022

I would need to play with the rule (and if I get some time today I will) but I would approach this way...

update the parent date if empty or if it is > the date in the child issue that triggered the event using the following smartvalue context

{{[date1].compareTo([date2])}}

Compares date1 to date2, to find which date is earlier. Returns: 

  • -1, if date1 is earlier than date2

  • 1, if date2 is earlier than date1

  • 0, if the two dates are the same

Examples

{{issue.duedate.compareTo(now)}}
//returns -1 or 1
{{now.compareTo(now)}}
//returns 0
Sinisa Glusac
Contributor
December 16, 2022

Hi Jack, 

thank you very much for your quick response!

However, I tried your solution, but it must be that I did something wrong (lack of Jira experience). No error in audit log, just "no action performed". 

Is this how automation should look like:

Screenshot 2022-12-16 163504.png

Suggest an answer

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

Atlassian Community Events