"Last Comment " filed required on Search Issue column and while export the XML report

Kumar
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 4, 2018

Hi Team,

I need an Last Comment in the Search Issue Column  to export the report file 

I have find a add-on instead of buying an add-on is there any way I can do by using the script runner 

can you please suggest me regards this .

 

Thanks,

Kumar

2 answers

1 accepted

0 votes
Answer accepted
Cristian Rosas [Tecnofor]
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 4, 2018

Well, you can use a listener to update a field with last comment.

Edited:

def issue = event.getIssue() as MutableIssue

and

def comment = event.getComment()

 You will need some imports also for MutableIssue and to update the value of the field

Kumar
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 4, 2018

Hi @Cristian Rosas [Tecnofor] Thanks for your response 

Here i understand please correct me if I’m wrong 

1st I need to create a custom field called “Last Comment(text field ) 

2nd script  listener and add a custom listener in that I have to add the script that you have provided 

if I’m wrong can you please explain more and how to achieve this please 

 

thanks,

kumar

Kumar
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 5, 2018

Hi @Cristian Rosas [Tecnofor]  I found a script to copy the comments in script filed and i'm adding that scripted filed to Export Report column

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.comments.Comment
import com.atlassian.jira.issue.comments.CommentManager
import com.atlassian.jira.component.ComponentAccessor

def commentManager = ComponentAccessor.getCommentManager()
def comment = commentManager.getLastComment (issue)
def date = comment.getCreated()

return ((date as String) + " " + comment.body)

 

This script is copying the comment and date that commented I'm just wondering the how can i add the user in the script 

I  want to copy the user name that who commented as well in the script

Can you please help me how to achieve this

 

Thanks,

Kumar

Cristian Rosas [Tecnofor]
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 5, 2018

Hey, I've seen you have advanced very well!

Something like this should work:

return ("Commented by " + comment.author + " on " + (date as String) + " " + comment.body)

or

return ("Commented by " + comment.getAuthorFullName() + " on " + (date as String) + " " + comment.body)

Here references:

https://docs.atlassian.com/software/jira/docs/api/7.2.2/com/atlassian/jira/issue/comments/Comment.html 

Kumar
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 6, 2018

Hi @Cristian Rosas [Tecnofor] 

Thanks for your response The script I modified an dits working as i expected

here is the script and I need a small help to need thing to work with in the script can you please help me how to do that 

 

import com.atlassian.jira.component.ComponentAccessor

def user = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser()
def commentManager = ComponentAccessor.getCommentManager()
def rendererManager = ComponentAccessor.getRendererManager()
def comments = commentManager.getCommentsForUser(issue, user)

if (comments) {
def commentAuthor = comments.last().getUpdateAuthorFullName()
def commentDate = comments.last().getUpdated()
def commentBody = rendererManager.getRenderedContent("atlassian-wiki-renderer", comments.last().body, issue.issueRenderContext)

return commentBody + "<p><span style=\"font-size:smaller;color:#a9a9a9;font-style:italic\">" + commentDate.format('YYYY-MM-dd') + " | " + commentAuthor + "</span></p>"
}

List of the things to work with script if possibel  

  • link to attached email
    • Pass
  • url
    • Pass
  • Image
    • Pass
  • Bold
    • Fail
  • Italics
    • Fail
  • Underline
    • Fail
  • Text header formatting
    • Pass
  • Text color formatting
    • Fail*
      • Only works if you format the color of the text in the comment. I tried to copy+paste text that was colored red into the comment but the color did not copy+paste.
  • Bullet lists
    • Pass

 

can you please tell how to make pass the fail list that i mention above 

 

Thanks,

Kuma

Maro Hamamjyan March 12, 2019

Hello Cristian,

I also want to be able to show the last comment in a report, can you please tell me what is listener that I need to update a field with last comment as you maintained in your answer. I am new in Jira development. What should be installed to get that listener?

 

Thanks in advance

0 votes
Aron Gombas _Midori_
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 10, 2019

"Last comment" is a calculated field that is available out of the box with the Better Excel Exporter app. You can use it to export the comment text, commenter user, comment date or all to Excel spreadsheets which can be the source of further data transformations.

See: https://midori-global.com/products/better-excel-exporter-for-jira/server/documentation/customization#calculated-fields

Suggest an answer

Log in or Sign up to answer