Getting Last comment from #lookupIssues using JIRA server

henry_lin December 9, 2024

This is similar to this issue to this. I am able to use the #lookupIssue and retrieve elements from multiple issues, but I am not able to retrieve the last comment of each issue. Is this because I am not in the cloud version of JIRA? Below is what I have, where comment doesn't display:

{{#lookupIssues}} 
{{#if(equals(status.name, "To Do"))}}
Ticket ID: {{key}}
Updated: {{updated.mediumDate}}
Summary: {{summary}}
Reporter: {{reporter.displayName}}
Assignee: {{assignee.displayName}}
Last Comment: {{comments.last.body}}
{{/}}
{{/}}
  1.  

    Ticket ID: Key-733
    Updated: Nov 12, 2024
    Summary: Create account
    Reporter: Jane Doe
    Assignee: John Doe
    Last Comment:
  2. Ticket ID: Key-544
    Updated: Nov 27, 2024
    Summary: Create Database
    Reporter: John Doe
    Assignee: Jane Doe
    Last Comment:

 

 

 

Also recieved suggestions on workarounds: 

  • use the bulk-handling feature of the Scheduled Trigger or branches, with the plural {{issues}} smart value
  • use the Send Web Request action to call the REST API to perform an issue search with JQL, and access the fields from the web response.

But any suggestions on what's the easiest considering the use case that I have?

2 answers

1 vote
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 9, 2024

Hi @henry_lin -- Welcome to the Atlassian Community!

For Jira Data Center, the Lookup Issues action does not yet support the Comments field:

https://confluence.atlassian.com/automation/jira-smart-values-issues-993924860.html#Jirasmartvaluesissues-lookupissueslookupIssues

https://jira.atlassian.com/browse/JIRAAUTOSERVER-877

 

There are two possible workarounds to replace the Lookup Issues action usage, depending upon the situation:

  1. use the bulk-handling feature of the Scheduled Trigger or Branches with the plural {{issues}} smart value: https://confluence.atlassian.com/automation/run-a-rule-against-issues-in-bulk-993924653.html
  2. call the REST API endpoint for issue search with JQL, using the Send Web Request action, and use the web response to access the fields

You could use the first one for your case.

The second is needed when your rule is already using branching or when you need the issue data to edit another issue.  For example, to sum such as Story Points into a parent Epic.

 

Kind regards,
Bill

0 votes
Trudy Claspill
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 9, 2024

Hello @henry_lin 

Welcome to the Atlassian community.

According to the documentation for A4J in the latest Jira DC version, that should work.

https://confluence.atlassian.com/automation/jira-smart-values-issues-993924860.html#

As an experiment can you add a line to print the number of comments associated with each issue? i.e.

Comment count: {{comments.size}}
Last Comment: {{comments.last.body}}
{{/}}
{{/}}
henry_lin December 9, 2024

Hi @Trudy Claspill 

Appreciate the quick reply! Implemented the {{comments.size}} and it returned a blank, but when looking at the specific ticket in JIRA, it does have comments, so I'm not sure why it's not returning me anything. For some reason, this only happens with #lookupIssue. If I remove this, I can retrieve the last comment for a single issue.

Suggest an answer

Log in or Sign up to answer