Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

How to get last comment in filter or JQL?

Do you want to monitor the last comment added to the issue? If you're a Jira user and it’s essential for you to get to know who and when has added the last comment, follow this short step-by-step guide.

LinkedIn (12).jpg

Step 1

First of all, you need to create a new custom field in the project for every Issue type. Type the name “Last Comment” for a custom field and choose the “Paragraph” type (as it is displayed in the screenshots below).

How to get last comment 1.1.png

Note: You should perform a step with adding a Custom field for each Issue Type (in our case these are e.g. Bug, Task, and Story as it's shown on  the screenshot)

Step 2

Then start the Automation process. Here’s what you should do:

Go to Project -> Setting-> Apps-> Project Automation -> Create rule

You can start when the Issue is Commented on and edit a custom field with the latest Comment. 

{

"fields": {

"Last Comment" :"[~accountid:{{comment.author}}] commented: {{issue.comments.last.body}}"

 }

}

2.1.png

Note:

  1.  Last Comment (highlighted in red color)  is a field name. If you name your field differently, please, specify the correct field name there. 
  2. You can format the text template based on which the message will be formed (highlighted in yellow). Copy the pattern from the example and  mention the author of the comment: [~accountid:{{comment.author}}] and display the text of a comment - {{issue.comments.last.body}}

Look at the screenshot below to get a clear view of how to do that properly.

 How to get last comment 2.2.png

Step 3

Go to JQL or native search, or any add-on.

 (for example Time in Status for Jira Cloud) -> Columns -> Select Last Comment field

As a result, you will see the custom field you have created with the latest value.

 How to get last comment 7.7.png

That’s all!

Now you know how to display the last comment in the filter, JQL, or any add-on too. 

If you want to track the time frames and team efficiency in your workflow process in a single safe place, you can try the Time in Status for Jira Cloud add-on. It helps to identify bottlenecks, prevent delays and increase work effectiveness. Have any doubts? Try it on the Atlassian Marketplace and enjoy the results. Your team will be fully satisfied with the provided functionality. 

Best Regards

SaaSJet Team

26 comments

Comment

Log in or Sign up to comment
Chris Thomas
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.
Jul 27, 2022 • edited

Thanks for this. Without this article I wouldn't have been able to get this working.

 

However I couldn't get the above to work, I needed the following:

 

{
"fields": {
"customfield_10XXX" : "{{issue.comments.last.body}}"

}}

Thanks for the article!

In ended up using the same code Chris posted.

However, is there any way to keep the original formatting of the comment?

E.g. including bullet points, maybe even links to other issues, etc.

Like Florian Demleitner likes this

Thanks really helpful article! 

Just wondering if there is a way for just the user display name and comment to appear than the script part showing as well in the filter ?Capture - Last Comment.PNG

Chris Thomas
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.
Sep 23, 2022

@Louise Woods Mine does not show the JSON brackets. Just a couple of thoughts:

  1. You could switch out the Last Comment in the code with the customfield_XXXXXX name.
  2. Disable the current automation and create a new one from scratch following the instructions.

Chris Thomas Thanks for your help it I have worked it out!

when I tag a specific user in the comment, JIRA reflects the account number as opposed to the name of the user in the 'Last Comment' field  How can this be fixed?

For example

most recent Comment :  (@ jane smith) can we rename the report?

Comes up in Last Comment in filters and dashboards as :

accountid:12345:123xx123-xx5x-4141-x05x-715x9100x1x8 can we rename the report?

Thanks for all this! Super useful, how would the code look like if I wanted to also add the Date when the last comment was made? in a YYYY-MM-DD or similar

Like Robyn Lorenz likes this

Hi @LaurenS ,

 

were you able to fix that? same problem here.

Thank you

@Tomas Arguinzones nope, haven't been able to figure it out

Hi @LaurenS 

I just figured it out!

Just change the renderer in the field configuration scheme for the field from free text to wiki style and it did the trick!

Like # people like this

Hi @Tomas Arguinzones  @LaurenS 

Tried to not resolved in last comment 

free text to wiki style received account id : 

Hi [~accountid:62c6c10a5f45fds3d3b7b76f5a] ,

Issue resolved please verify ,

Screenshot 2022-11-06 225058.jpg

issue resolved! thank you very much @Tomas Arguinzones 

@LaurenS 

Can you please let me know how did you resolved am still getting the same issue 

Hi [~accountid:62c6c10a5f45fds3d3b7b76f5a] ,

Issue resolved please verify ,

If anyone tagged in the last comment it only gives me there iD 

{{issue.comments.last.body}}

Did anyone ever figure out how to post the date of the last comment in that custom field?

Having the last comment is useful, but having the date in there of when it was posted would be helpful as well.

Like Carl Palmquist likes this

@Robyn Lorenz   I'm just using the Smart Value {{now}} to add the current date (and time if you want) when the last comment is copied into the Most Recent Comment field.  (Size gives the total number of comments.)  Like this:

{{now.shortDate}} | {{issue.comments.last.author.displayName}} | {{issue.comments.last.body}} | {{issue.comments.size}}

Most Recent Comment.JPG

Like # people like this

Fantastic @Randall Huber !! :D Great work. Wonder if it could be possible to change the date format into my preferred YYYY-MM-DD or something similar.. but still fantastic!

@Randall Huber nice!  Thanks so much!  That worked wonders!  I just did the date / name on one line and the comments on another.

{
"fields": {
"Last Comment" :"{{now.shortDate}} {{issue.comments.last.author.displayName}} \n {{issue.comments.last.body}}"
}
}

Thanks again!!!

Like # people like this

The problem I have is that every time the comment contains an empty line or a line break, the automation is not performed and the comment is not transferred to the Last comment field.

For example when someone comments:

"Hello,

this is a comment."

Does anyone have a solution for this?An answer to this question would help me a lot :)

Like Paul Campbell likes this

@Florian Demleitner I'm using this:

{
"fields": {
"Last Comment": "On: {{now.shortDate}}\n {{comment.author.displayName}} wrote:\n{{issue.comments.last.body}}"
}
}

And I just did a test with line breaks in it and I did not have the problem you mentioned

@Paul Campbell  Thank you very much now it works with your solution :). Something must have been wrong with my customfield.

Like Paul Campbell likes this

Would some version of this configuration work in server/data center?

Like Lucile Cornet likes this

Hi all ! I was wondering the same question as Christina. Could this work on Jira DC or do you know an alternative ?

Like Christina Cuffari likes this

@Robyn Lorenz , worked perfectly, thank you so much

Screenshot 2023-07-31 225158.png

TAGS
AUG Leaders

Atlassian Community Events