Want to Copy Fix Versions from Epic to "Parent Link"
Asked by Doug Levitt:

We are using Advanced Roadmaps and have the following hierarchy:

* Capability
  * Epic
    * Story
      * SubTask

An **Epic** is related to a **Capability**using a "Parent Link".

I am interested in writing a ++schedule++ automation that, for each **Capability** , evaluates its Chlid Issues (which are **Epics** ) and sets the FixVersion in **Capability** based upon the set of FixVersion assigned to all of its child **Epics**(and, of course, it is possible for an Epic to have multiple Fix Versions).

So, as an example, imagine we have Capability-123 which has 4 Child **Epics**

* CAPABILITY-123
  * EPIC-44 (FixVersion = "1.2.3")
  * EPIC-45 (FixVersion = "4.5.6")
  * EPIC-46 (FixVersion = "4.5.6", "4.5.7")
  * EPIC-47 (FixVersion = \<empty\>)

After the job is run, I want CAPABILITY-123 to have FixVersion = "1.2.3", "4.5.6", "4.5.7".

So, I know for each **Capability** , I can use "Lookup Issues" to find its member **Epics** (using JQL "Parent Link" = {{triggerIssue.key}}.

Likewise, I know the resultant Smartvalue, {{lookupIssues.fixVersions.name}}, contains a list of the issues.

* \[1.2.3\], \[4.5.6\], \[4.5.6, 4.5.7\], \[\]

But I wasn't clear how to use this to edit the **Capability's** Fix Version. I tried using Advanced Branching, hoping it might iterate over each FixVersion in {{lookupIssues.fixVersions.name}}, but that didn't work.

Any ideas how to propagate the FixVersion "up" in the hierarchy (from the **Epic** to the **Capability**)?

P.S. - I know I can do this via a Trigger looking for Field Value Changed on the "Parent Link" field. But...there are a bunch of corner cases (an **Epic** can be added to a **Capability** , an **Epic** can be removed from a **Capability** , the Fix Version on an **Epic** can be added/removed). As such, I was hoping to just "roll up" the Fix Versions from the **Epic** to the **Capability** on a nightly basis.

Any ideas and/or suggestions would be deeply appreciated.

Thanks.


Answers:
author: Jeffrey Bistrong
body: Have you tried using the {{parentlink}} smart value as described here: [https://community.atlassian.com/t5/Automation-questions/Transition-Initiative-to-In-Progress-when-Epic-starts/qaq-p/1724671?utm_campaign=kudos_comment\&utm_content=post\&utm_medium=email\&utm_source=atlcomm#M1820](https://community.atlassian.com/t5/Automation-questions/Transition-Initiative-to-In-Progress-when-Epic-starts/qaq-p/1724671?utm_campaign=kudos_comment&utm_content=post&utm_medium=email&utm_source=atlcomm#M1820)

Not quote sure if it will work for your use case, but this article seems pretty similar

comments: author: Doug Levitt
body: Hi [@Jeffrey Bistrong](/t5/user/viewprofilepage/user-id/1190841)

Thanks for sharing the link. I had tried something similar, but that didn't work.

With that being said, I did figure out my problem with using Advanced Branching. I was doing it wrong. I needed to iterate over each FixVersion using {{lookupIssues.fixVersions}} and placing the array into a new Variable name (e.g thisFixVersions) and then referencing that using {{thisFixVersions.name}}.

Also, I figured out how to place the Fix Versions into a comma-separated list, removing the square brackets and removing the empty Fix Version.

As a result, from Capability-123 which has 4 Child **Epics**

* CAPABILITY-123
  * EPIC-44 (FixVersion = "1.2.3")
  * EPIC-45 (FixVersion = "4.5.6")
  * EPIC-46 (FixVersion = "4.5.6", "4.5.7")
  * EPIC-47 (FixVersion = \<empty\>)

I was able to do the Advanced Branching on Smart Value = 1.2.3, 4.5.6, 4.5.6, 4.5.7

However, I am ++**still**++ having a problem. As once I get into the Branch, I am trying to update CAPABILITY-123, by ++**adding**++ the Fix Version. But this isn't working. I think because each Branch is running in a separate thread and the threads are colliding with one another. So, rather than ending up with CAPABILITY-123 having FixVersion of 1.2.3, 4.5.6, 4.5.7, it is somewhat randomly being assigned to only one of those values. If I run the schedule automation again, another one gets added.

This leads me to my next question. I don't need to store these values in the jira Fix Version field. I could put them in another field. However, I don't know how to unique that list.

Question - Does anyone know if it's possible (within Automation for Jira) to take a comma-separated list of values and unique that list. So, in this case, it would only have "1.2.3, 4.5.6, 4.5.7".

I realize Automation for Jira is not a programming language. I am just trying to think if there is a way to implement this requirement.

Thanks.


author: Mark Chaimungkalanont
body: There is a "distinct()" function that you can use, as long as the underlying object is a list. Although, if the actual object aren't Strings underneath, mileage may vary. eg.

```
{{issue.comments.author.distinct)}}
```


author: Doug Levitt
body: [@Mark Chaimungkalanont](/t5/user/viewprofilepage/user-id/475825)

I tried the distinct function. It didn't quite work on my use case. As I had a Capability with 4 Epics (where each Epic was assigned to one or more Fix Versions). I was unable to figure out how to get a single, unique list of Fix Versions across all 4 Epics.