Improve JIRA dashboards by showing the last issue comment

  • Taille du texte: Agrandir Réduire
  • Notifications
  • Imprimer

A quick way to improve your Filter Results gadgets in JIRA dashboards or in the Issue Navigator is to include a column that shows the last comment. Today I will provide a SIL (Simple Issue Language) recipe to do just that. 

This recipe addresses a limitation of JIRA where it is not possible to show the last issue comment. This limitation is being tracked on Atlassian's public JIRA site with key JRA-2734.

Disclaimer: This recipe involves scripting, which is curretnly not possible with JIRA OnDemand. See Restricted Functions in Atlassian OnDemand for more info.

Another Disclaimer: You could also purchase the CCC Last Comment plugin, but why buy countless plugins when you can do a tons of great things with one or two plugins. Plus what I'm about to show you gives you much more flexibility.

 Shameless plug: I contributed the idea of having a getLastComment() routine in SIL.


How to do it:

Assuming you've installed the KCF add-on in your JIRA instance, you are ready to go.

#1 Create the Last Comment custom field

Go to the Custom Fields section of JIRA Administration, and click on the Add Custom Field button in the top right corner. Click on Advanced in the left column and select SIL Script Custom Field by double clicking on it. Enter Last Comment as the field name, click Next, and (optional)select some screens to add it to. Note that if you're only interested in using the field in dashboards / search results, you don't need to add it to any screens.

#2 Add the SIL Script to the Last Comment field

Ok, so now you've created a SIL Script Custom Field, but it won't work until you add an actual script. The field itself is like a car body, and we're about to add an engine. In order to do so, find your field in the list of custom fields and use the Gear icon b2ap3_thumbnail_JIRA-gear-icon.png on the same line to access the Configure link. On the next screen you'll need to click on Edit SIL Script. That's where you'll paste the following code snippet:

string[] lastCommentDetails = getLastComment(key);

    return lastCommentDetails["text"];
return "";

#3 Add the field on your dashboards through the Filter Results gadgets 

As far as the custom field itself, you're already done. The only left to do is to add the field in a Filter Results gadget. Assuming you already have a Filter Results gadget, simply edit the gadget and field the field like so:


#4 Add the field in your Issue Navigator

You can also add the field in your JIRA search results. Simply click on the Columns button and add the Last Comment field:


Extra - Improve the Last Comment field to include the name of the last commenter

When I use the SIL Script Custom Field Last Comment, I also like to include the name of the last commenter. Of course, you could decide to create another SIL Script Custom Field called Last Commenter, it's up to you really. Since I'm a JIRA Minimalist, I'd rather have one field do twice the work!

Here is the SIL script you can use to display the name of the last commenter, followed by a colon, followed by the text of the last comment:

string[] lastCommentDetails = getLastComment(key);

    return userFullName(lastCommentDetails["author"]) + ": " + lastCommentDetails["text"];
return "";

And you will get something like this:


How it works

If you are a keen observer and have some coding experience, you'll notice the variable lastCommentDetails is actually an array. The getLastComment routine I'm calling returns an array with all the information found in the last comment. It contains these properties accessible via array keys:

Key name



the id of the issue comment

text the comment text
author the author of the comment
created creation date, as string, can be assigned to a date variable
updatedBy the updater, or empty string if there is no updater
updated updated date, or empty string if there's no update

Knowing that, it's now up to you to customize your Last Comment field to your liking !

This post was tested on JIRA 6.1.3

Update - Handling Comment Visibility

The initial version of the SIL script for the Custom Field did not account for comment visibility. This meant that the user would see the comment, regardless of the visibility of the comment, which could lead to some problems. Here's an updated version of the script.

string[] lastCommentDetails = getLastComment(key);

if(userHasAccessToComment(currentUser(), lastCommentDetails["id"])){ return userFullName(lastCommentDetails["author"]) + ": " + lastCommentDetails["text"];
} } return "";

Of course, you could decide to return a generic message to when the user does not have access to the comment. I chose to hide it completely, following JIRA's way of doing things, a way which I don't always agree with Wink

Update #2 - Choosing the proper renderer

If you have JIRA Power Users that are using markup to add rich comments, these may not show up properly in your Dashboards and/or Issue Navigator. For example, I added a comment which included a very long link. Here is how it appears in my dashboard:


See how the Last Comment is broken here?

This is actually something you can fix fairly easily. The solution is to go through all your Field Configurations and change the Renderer for the Last Comment field.

For example, if we go in the Default Field Configuration and locate the Last Comment field in there. See how Last Comment is using the Default Text Renderer? We need to change that.



So click on Renderers, and select the the Wiki Style Renderer, then click on the Update button



Now unfortunately, you must repeat this task for all your field configurations. But, now you will get the expected result in your dashboards!



Big thanks to commenter prasad for letting me know about this, totally forgot to mention it!

dans JIRA Lectures : 47736 22 commentaires


  • Invité
    Andrew mercredi, 12 février 2014

    Hi Felix,

    Thanks for posting this - I plan on giving it a go.

    Are you able to tell me, will the last comment field be visible in XML exports of search results, and as such, can be displayed on Confluence via the Jira Issues plugin?

    Again, many thanks

  • TechSolCom
    TechSolCom lundi, 17 février 2014

    Hi Andrew, good question. I went ahead and tested it and Last Comment will show up in the XML exports and it will show up on a Confluence page through the JIRA Issues Macro. (Tested on Confluence 5.1.5)

  • Invité
    Jeff vendredi, 14 février 2014

    This makes the move from our previous issue tracker (which had this) much easier! Thanks for the good idea.

  • Invité
    Blake lundi, 03 mars 2014

    I was attempting to do the same thing with a SIL Post Function. This is much better! Thanks so much, this guidance is appreciated!

  • TechSolCom
    TechSolCom mardi, 04 mars 2014

    Glad you liked it, I'm planning more posts about SIL, stay tuned !

  • Invité
    Dave mercredi, 04 juin 2014

    This is exactly what I've been looking for! JIRA's default "Last Comments" field was limited to only a set number of characters which cuts off the comments and makes me open each issue to view the comment which basically makes the field useless. With this extremely easy to implement SIL script I had the field up on my dashboard in under 5 minutes. Thanks for posting this!

  • Invité
    Jana lundi, 30 juin 2014

    what is your twitter ID? I am trying to follow you and can't find you.

  • TechSolCom
    TechSolCom lundi, 30 juin 2014

    Hi Jana, thanks for your interest in this blog. My twitter ID is heffem. Cheers.

  • Invité
    Jason Stubbings vendredi, 17 octobre 2014

    This is a nice little SIL script but has one BIG issue. If you are using restricted comments, it exposes the restricted comment (if last comment) to anyone running a issue navigator report. Is there anyway to enhance to check currentuser() to see if they have authority to the last comment?

  • TechSolCom
    TechSolCom mardi, 21 octobre 2014

    Hi Jason, you bring up a valid point. Currently there is no way in SIL to determine if a user has visibility on a comment. I have contacted the team at Kepler-Rominfo and requested this feature, I'll do my best to keep everyone posted in this comment. I know the team is hard at work on wrapping up SIL 3.0, so it may be a while before it happens.

  • Invité
    Jason Stubbings mercredi, 22 octobre 2014

    Thanks Felix.

  • TechSolCom
    TechSolCom jeudi, 23 octobre 2014

    Seems you beat to the punch with submitting a ticket on the Kepler Tracker :)

    Other interested in following this, you can watch/vote

  • Invité
    Jason Stubbings lundi, 15 décembre 2014

    I quickly updated the script and it appears to be working. Might not be the tidiest implementation - let me know what you think:

    string[] lastCommentDetails = getLastComment(key);
    boolean accessCheck;

    accessCheck = userHasAccessToComment(currentUser(), lastCommentDetails["id"]);

    if(accessCheck) {

    return userFullName(lastCommentDetails["author"]) + ": " + lastCommentDetails["text"];
    return "** Secure comment **";

  • TechSolCom
    TechSolCom lundi, 15 décembre 2014

    Hi Jason,

    Thanks for providing an updated version of the script, looks good! I'll also update my original script.

  • TechSolCom
    TechSolCom lundi, 08 décembre 2014

    With the release of SIL 3.0 last week, this has been addressed!

    See for more details :)

  • Invité
    Andrea mercredi, 29 octobre 2014

    Hi Felix,
    great tutorial, thanks.
    I've one question, because we have for comment an import of an email, can we restrict the SIL script in order to view only the first row comment (collapse comment) and permit to expand the row in order to view all?



  • TechSolCom
    TechSolCom mercredi, 29 octobre 2014

    Hi Andrea, yes you could certainly do that. You'd need to use the chop routine to keep the first X characters of the comment. Up to you to decide how many you want to keep. See for more information.

    If you want to be extra fancy, you could apply this "rule" only if the comment is longer than a certain numbers of characters!

    Unfortunately, you won't be able to "expand" directly from the Issue Navigator, you'll need to access the issue and view the full comment there.

    Hope that helps, thanks for your comment :)

  • Invité
    Andrea samedi, 01 novembre 2014

    Hi Felix,

    thanks for your comment.
    I have do some test and the script works great.

    There is a problem when I export last comment in excel, in fact (I use jira 5.2.11) if I export the entire comment the generated excel file is corrupted, instead, if I use chop function and cut at 512 character the export is perfect, if I cut at 513 charcacter the file generated is currupted.

    I don't know how export to excel work, so probably soma declaration of variable is wrong in some file?

    P.s. because you are the ideator of the function getLastComment, I have an idea of another function:
    the new function should extract the status of the art of entire transaction of the issues, one example:

    a) in date xy the user has approved the issue and the status changed from unapproved to approved
    b) in date zt the user has changed the status from approved to new enanchements request
    c) etc etc.... until the last status



  • TechSolCom
    TechSolCom lundi, 03 novembre 2014

    Hi again. Since you mention Excel, you may want to have a look at the Exporter plugin for JIRA. A few of the organizations I work with use it. It can export all the comments and transition history to Excel.

  • Invité
    prasad vendredi, 19 décembre 2014

    Hi Felix, This last comment functionality was very useful. One small clarification, currently it is dumping the text data, from the html format in the JIRA comments field.
    If there is any HTML data for formatting and links. The last comment shows pages of data , basically the HTML source data, is there a way to take it as HTML content and paste it in last comment?

Commenter cet article

Invité samedi, 19 janvier 2019