It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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

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

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

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

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 

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

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

"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
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you