Comment on linked issues (not the issues in the release) when a Version is Released
Asked by Tyler Monroe:

I'm struggling to figure out if this is possible.

Here's the scenario: When a ticket comes into the service desk project, we link that ticket to another ticket in the actual engineering project where the work is executed (simply using the linked - "relates to" relationship).

Right now when we fix bugs related to those service desk issues in a release, someone has to go back to the service desk tickets and comment in them to the effect of "this was fixed in version xyz", so the service desk team knows they can close out the issue and/or let the customer know.

So I'm trying to build an automation that does the following:

When a version is released, look through all the tickets that are part of that release, then comment on any tickets LINKED to those (NOT comment on the tickets in the release itself). This feels like it should be simple, but I'm having trouble with the logic to make it happen.

Thanks in advance for any help you can provide.


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

Which version of Jira are you using: Cloud, Server, or Data Center?

The different versions have different automation capabilities, so knowing the version will help to focus any suggestions.

For now, I will assume Jira Cloud or Data Center...

First, your rule will need to be multiple-project or global in scope because it is trying to access / edit issues in a different project. Your Jira Site Admin will need to help create such a rule (or change the scope of your rule).

Next, this would be easy to solve if automation rules supported nested branching, but they do not. And so a workaround is needed to get those linked issues: using Lookup Issues as a go-between.

* action: lookup issues, use JQL to get the issues in the released version
* branch on JQL: using the results of the lookup to find the service project's linked issues, based on the project and link types
  * action: add your comment to the relevant issue

That *branch on JQL* may need to use dynamically-generated JQL from the lookup. For example...

```
project = yourServiceProject AND?
  (
    {{#lookupIssues}}
    issue IN linkedIssues({{key}}, "relates to") {{^last}} OR {{/}}
    {{/}}
  )
```

How that works...

* assume the project of the needed issues is the service project
* and [iterate over the results](https://support.atlassian.com/cloud-automation/docs/jira-smart-values-lists/#Combined-function-examples) of the lookup issues
* adding JQL to [find linked issues of the desired link type](https://support.atlassian.com/jira-software-cloud/docs/jql-functions/#linkedIssues--)
* finally, adding OR to separate the clauses for all except the last one found

Please check the link types / direction to confirm they match your needs.

Kind regards,  
Bill

comments: author: Darryl Lee
body: Gah, [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) you beat me again!

Great job asking if [@Tyler Monroe](/t5/user/viewprofilepage/user-id/5541061) might be on Data Center. If so, then he might have access to the [ScriptRunner JQL Functions](https://docs.adaptavist.com/sr4js/latest/features/jql-functions) that I mentioned that could make this ***much easier**.*

But as I mentioned, you and John already solved this for Cloud w/o access to ScriptRunner functions.


author: Bill Sheboy
body: Yes, and...I neglected to add the dynamic JQL in that prior question's response, so I added it this time :\^)


author: Darryl Lee
body: OH man, dynamically generated JQL. I didn't think about that.

I thought you could just iterate through each issue from the original lookup, but augh, yeah, I guess that'd require another branch, which is a no-go.


author: Bill Sheboy
body: With Jira Cloud, (I believe) the issuelinks smart value could be parsed with smart value, list filtering to get the needed ones in one step. But that smart value [does not exist yet for Data Center's version of Lookup Issues](https://jira.atlassian.com/browse/JIRAAUTOSERVER-877). The dynamic JQL should work for both Jira versions.


author: Tyler Monroe
body: Thanks gents - this is a little more complex than I was hoping it would be, but at least it'll get the job done!


author: Darryl Lee
body: Heya [@Tyler Monroe](/t5/user/viewprofilepage/user-id/5541061) yes, this definitely should be do-able, although... it'd be a lot easier with ScriptRunner [JQL Functions](https://docs.adaptavist.com/sr4jc/latest/features/scriptrunner-enhanced-search/jql-functions), which would let you do something like:  

```
project = SDP and issueFunction in linkedIssuesOf("project=CD and fixVersion={{version}}")
```

(Although argh, because of [changes in Cloud](https://docs.adaptavist.com/sr4jc/latest/features/scriptrunner-enhanced-search) I don't think this is possible :-{)

But since we probably can't do that, you'll need to do Advanced Branching. Luckily [@John Funk](/t5/user/viewprofilepage/user-id/5415940) and [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) already answered a similar question to this, which saves me some time:

* [Automation for Version Release Trigger](https://community.atlassian.com/t5/Jira-questions/Automation-for-Version-Release-Trigger/qaq-p/2362507)

Let us know if that solves things for you!

comments: author: Darryl Lee
body: BTW, I cribbed that JQL from this article:

* [How can I search for all tickets that have issue links to another project?](https://community.atlassian.com/t5/Jira-questions/How-can-I-search-for-all-tickets-that-have-issue-links-to/qaq-p/1231423)

Which links to this great thread about using the ScriptRunner functions to search for specific linked issues:

* [Filter to find issues with links to other issues which are unresolved](https://community.atlassian.com/t5/Jira-questions/Filter-to-find-issues-with-links-to-other-issues-which-are/qaq-p/281971)

But again, the huge caveat is that you would only be able to do this if you are on Data Center and have ScriptRunner, because Adaptavist (ScriptRunner's vendor) is not able to make those functions available in "regular" JQL queries, such as the ones that Automation uses.