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

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


1 badge earned


Participate in fun challenges

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


Gift kudos to your peers

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


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!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Adding "last comment" in a Filter Results Dashboard

I am wanting to show the "last comment" written in a JIRA to provide an overall status. 

 I was just wondering on when you create a dashboard if there is a way to add in the last comment added in a JIRA to a gadget in the "columns to display"? I added "comments" listed in the columns to display option but nothing pulled up. I am using the JIRA3 instance. Thanks!

2 answers

2 accepted

7 votes
Answer accepted

Are you using Jira Cloud or Jira Server/Data Center? There's no way to do this by default in either case, so you'll need some add-on to help you with this.

If Cloud, this link might be helpful to you:

If Server/Data Center, you can definitely achieve this probably using the same steps as in the last link above using Automation for Jira Lite, but if you have ScriptRunner installed, you can create a scripted field using this script:

* Field name: Last Comment
* Template: Text Field (multi-line)
* Description:
* Returns the last comment on an issue.

import com.atlassian.jira.component.ComponentAccessor

// get the latest comment
def commentManager = ComponentAccessor.getCommentManager()
def comment = commentManager.getLastComment(issue)

// check to see if comments exist - return comment body if so
if (comment != null) {
return comment.body

return null

This was exactly what I was looking for after trying the JQL Function and realizing I needed to display the data in a field.



Sounds good :)

Nice work. This is extremely helpful.

Hello Alex_Christensen,

Thanks for the script. It works. 

I created a Custom Script Field, Field Name = Comment(customfield_10845).

I added this customfield Advanced Settings to jira.table.cols.subtasks in order to show the latest Comment customfield under parent-task. When I add a comment to sub-task and I put it a restriction (Restricted to jira-administrators) only jira-administrators can see the comments in the sub-task but under parent task every project user can see this comment field. Can we add a kind of restriction to this script ?



@Alex Christensen Could you add, please some, disclaimer, around performance degradation, and some limitationss etc. 

1. for example, users from one of my instances, want to implement it, But they have 1 - 3 mln cases, +1-5k daily increase + used 120k symbols for the text limits as results want to have boards with last comment.

2. Technically, it's easy implement, but before they should understand writing bots and doing a lot of updates and checking via dashboard it's not good way. 

3. Once if you want to migrate to another DB, or data, you will meet with limits. 

4. Also, script should have some truncate function to have a strict rule. 



Gonchik Tsymzhitov

Could this be used to pick out the last Customer comment or the last internal comment?

What about the date of the last comment and the user who made the comment?

2 votes
Answer accepted

Hi Stephanie,

I can confirm that if you are using Jira Cloud that it is not possible to create a Scripted Field like you can do with ScriptRunner for Jira Server.

The reason we are unable to provide this functionality is due to the restricted functionality and API's which Atlassian provide inside JIRA Cloud, due to the fact that Atlassian only provides a Rest API in Jira Cloud and not the same Java API that the server version contains.

You can see more detailed information on the differences between ScriptRunner for JIRA Cloud and ScriptRunner for JIRA Server inside of the documentation page located here.

I can, however, confirm that the closest functionality to a Script Field that can be achieved in Jira cloud is a Script Listener which calculates a value on an issue as described inside of the documentation page here.

The Script Listener would need to be configured to fire on the Issue Updated event and would need to call the Get Comments API documented here to get all the comments from an issue and then to add the text from the last comment to a custom Text field.

If this response has answered your question can you please mark it as accepted so that other users can see it is correct when searching for similar answers.



Thanks, Kristian! I appreciate the response. 

@Alex Christensen  i need to add comment restriction also in the last comment so can you tell me how to do it?

Hi @Rajesh Ramankutty 

If you want to restrict comment on the issue, restrict it from Permission Scheme. Or If you want to customize and restrict Last Comment field to other projects, just add the context. 

How do I actually do that I keep getting all kinds of errors. Can we see example code to retrieve the last comment from jira cloud using a script listener?

Hi Mark,

Thank you for your response.

I have created some simple example code located here which when configured to run on the Issue Updated event in a Script Listener in ScriptRunner for Jira Cloud will get the text from the last comment off an the issue and save it to a variable.

You will be able to use this as a reference to help you create the script that you require.

I hope this information helps.



Thanks so much Kristian. 

And to put this into a custom field called "Last Comment" ID 10093 would you be able to help me with the put statement that follows on from this? 


I really appreciate this

Hi Mark,

Can you please advise what type of field the Last Comment Field is?

I can confirm that in our documentation site located here that we have lots of examples of how to set different fields and the example located here shows how to set a text field and you can change the summary field to your custom field if you wish to set a text field by specifying the ID for the custom field.

I hope this information helps.



Hi Kristian,


The Last Comment Field I made is multi-line text. 
I'll give the advice a try and see what the result is. 

Again thanks


So I tried it and it works for any plain text and multi-line text. As soon as I put in bullet points into my comments though it breaks:

// Get the key of the current issue
def issueKey = issue.key

// Make a call to the Get Comments API to get all the comments on the issue
def getComments = get("/rest/api/3/issue/${issueKey}/comment")
.header('Content-Type', 'application/json')

// If the issue has comments
if( != 0){
// Save the last comment to a variable called lastComment
def lastComment = getComments.body.comments.last().body.content.content.text.toString().replaceAll("\\[", "").replaceAll("\\], ", "\n").replaceAll("\\]", "").replaceAll(", null, ","\n")

//This is my custom field ID for Last Comment

def customFieldName = 'customfield_10093'
def result = put("/rest/api/2/issue/${issueKey}")
.queryString("overrideScreenSecurity", Boolean.TRUE)
.header('Content-Type', 'application/json')
fields: [
(customFieldName): lastComment

// log out the last comment"The Last Comment = " + lastComment)

if (result.status == 204) {
return 'Success'
} else {
return "${result.status}: ${result.body}"
// If the issue has no comments log out message to say this."The issue has no comments")

Is there anything that can be done to show bullet points? 

Also if I wanted it to only apply to projects of a project category called "IT" only can that be done as a check? 

Thanks again for the assistance. 

Hi Mark,

Thank you for confirming you got the script to work for a text field. 

I can confirm that the example provided is setting the field as a string and I do not believe that Atlassian allow you to retrieve the formatting of the comment as the API's do not allow this.

You may wish to look at using a Groovy Multi Line String if you wanted to save the value to a multi line text field and to try to format this text yourself that is displayed, but I do not have any examples of how to do this that I can share with yourself. 

As for limiting the listener to all projects in the IT category then I can confirm that this is not possible but that you can specify just the projects that the listener should run for in the Projects box when editing the Script Listener.

I hope this information helps.



Hi Mark,

I have just tested your code and can confirm that the get comments API does not appear to support getting the formatting for comments which have complex formatting in them such as bullet points etc.

However, I noticed as a workaround if you place the formatting in a noformat block using the syntax which you can see by navigating to the url of <JiraBaseURL>/secure/WikiRendererHelpAction.jspa?section=advanced in your instance then you will be able to show formatting such as a bulleted list in its raw wiki format.

I hope this helps.



Hi Kristian,


Do you mean if I place the output from my comment into a no format block and then put this into my Custom Field it will actually preserve the bullet points?
I'm a little confused where the no format block should be utilised?

Hi Mark,

I meant if you place the no format block in your comment and then put the bullets inside this in the comment that it will return the markup for the comment.

This means the custom field would then show the bulleted list similar to below where it uses a * symbol to indicate the bullet point.

* a 
* bulleted
* list

This means the formatting wont be the same as in the comment but as mentioned previously it is not possible to extract the same formatting as the Atlassian API's does not allow this so this is the closet to getting it that you will be able to achieve.

I hope this information helps.



Suggest an answer

Log in or Sign up to answer