Collect all Summaries from JQL request by Groovy

Harry
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 29, 2022

Hi there, 

I need to collect all summaries of Epic's issues in one comment and do it by JMWE Event-based actions.

I created Event-based action "comment related issue".

I can find all issues with type Task or Story and Component "BA" in Epic by:

jqlSearch("project = ${issue.get("project")?.key} and component = BA and issueFunction in issuesInEpics('key=${issue.get('customfield_10008')}') and type in (Task, Story)", 20)

where 

project = ${issue.get("project")?.key} is getting current project of current issue;
customfield_10008 is 'Epic Link' field and
issueFunction in issuesInEpics('key=${issue.get('customfield_10008')}') is query for all issues where Epic Link is the same as in triggered issue.


I get:

Result type:
Collections$UnmodifiableRandomAccessList
Result value:
[DocumentIssueImpl[issueKey=PROJ-362], DocumentIssueImpl[issueKey=PROJ-360], DocumentIssueImpl[issueKey=PROJ-359]]

 

But how can I collect all summaries from this 3 issues and put it into one comment?

1 answer

1 vote
David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 30, 2022

Hi @Harry ,

the jqlSearch function returns a list of Issue objects. You can access fields of these issues in many different ways, such as iterating over the list, using the *. operator, using the join method, etc.

For example, to return a bullet list of the issue summaries with links to the issue, you can use something like this:

def issues = jqlSearch("project = ${issue.get("project")?.key} and component = BA and issueFunction in issuesInEpics('key=${issue.get('customfield_10008')}') and type in (Task, Story)", 20)
issues.collect{
"* [${it.summary}|${it.url}]\n"
}.join()

Of course, if you're using a Groovy Template value for the comment, you'll need to put this in a <% %> block:

Look at these issues:
<%
def issues = jqlSearch("project = ${issue.get("project")?.key} and component = BA and issueFunction in issuesInEpics('key=${issue.get('customfield_10008')}') and type in (Task, Story)", 20)
print issues.collect{
"* [${it.summary}|${it.url}]\n"
}.join()
%>

Suggest an answer

Log in or Sign up to answer