Distinct List of FixVersions of linked issues
Asked by Enrico_Hribal:

Greetings,

I?m currently working on an automation with the goal to collect fixVersions of all linked issues and fill a field with them. I basically already got that solution. When I link an issue or multiple issues at once in project A issue A the linked issues from project B will get written down in the description field (just for test purposes) of issue A. Now I wanted to get the next step: If some fixVersions appear multiple times I only want them in the field once.

Here is my current solution:![automation.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/332950i7D06CEC1892C45B3/image-size/large?v=v2&px=999 "automation.PNG")

I?m kinda new to automations and smart values and it still confuses me a little bit. I know that you can go through list fields with {{#}} but first I need to create a list of the fixVersions to parse through? Any ideas on how to work this through?


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

First thing, **what problem are you trying to solve by *replacing the description* of the linked issues with a URL to the Fix Versions for each issue?** That is, "why do this?" Knowing that may help the community to offer better suggestions.

Until we know that...

When inside of an iterator, such as {{#issue.issuelinks}} ... {{/}} the *issue* prefix is not added: the scope is the issuelinks content and so only the field smart values are referenced.

Next, the smart value issuelinks has more structure than you show as link types have *direction*, such as "blocks" versus "is blocked by". And so a rule must select the ones you want, with {{issue.issuelinks.outwardIssue}} or {{issue.issuelinks.inwardIssue}} for the different directions.

Finally, smart values like issuelinks *do not contain all data for those linked issues*, such as the Fix Version field. If they did, a chain of issue links could theoretically pull in all issues in the entire Jira site! The workaround for this is to identify the keys of the issues you need, and then use the Lookup Issues action with JQL to gather their complete data...up to the limit of 100 issues.

Kind regards,  
Bill

comments: author: Enrico_Hribal
body: Greetings [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313)

thanks for taking the time. Like I mentioned earlier, the description field is just used for testing. There is supposed to be a different custom field that I would create for this purpose.  

The basic idea is based on the workflow shown below. The goal is to have a field in "Jira Task" (top left) which shows a list of all fixVersions that are included in the issues shown below (Bug, Maintenance, Feature). Those issues are either directly linked to the "Jira Task" Issue or are part of the epic shown in the top right, which is also linked to the "Jira Task" - issue. Each fixVersion should only be shown once if there are multiple issues with the same fixVersion.

I?m still pretty much in the early phase of finding a perfect solution for this problem. Any help is appreciated!

![workflow.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/333250i1DB56009D809F16B/image-size/large?v=v2&px=999 "workflow.PNG")


author: Bill Sheboy
body: From what you describe, it appears you are trying to *gather a distinct list of the Fix Versions in the linked issues (i.e., Feature, Bugfix, and Maintenance) and store that distinct list in a field in the Task*. If that is correct...

Your rule shown uses a branch, and that will not allow updating the Task.

Instead consider using the [Lookup Issues action](https://support.atlassian.com/cloud-automation/docs/jira-automation-actions/#Lookup-issues) with JQL to find the needed linked issues. Once those are available, all of their Fix Versions could be expanded into a comma-separated values list and cleaned up to remove the nested arrays with the [remove function](https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/#remove-String-remove-). Finally, that could be [split](https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/#split-String-separator-) and reduced using the [distinct function](https://support.atlassian.com/cloud-automation/docs/jira-smart-values-lists/#list.distinct) to get the unique ones.

```
{{lookupIssues.fixVersions.name.join(", ").remove("[").remove("]").split(", ").distinct}}
```

Please note well: these will be the names of the versions, and not the links to open them as version on the releases pages.


Tags: automation

cloud

fixversions

jira-cloud