Jira export bulk comments with Scripted fields

Hi, 

I want to export bulk issue with "all comments" with author name to excel sheet, and i used scripted field with following script:

import com.atlassian.jira.component.ComponentAccessor
def comments = ComponentAccessor.commentManager.getComments(issue)
if (comments) {
comments.body
}

It does the job, but it brings all the comments together in one line. Can someone please help to break each comments in to new line with author's name on the top of each comment?

I also tried to add the author name with following code:

comments.authorFullName

but it removes the comment and display only author's name.

Can someone please help me to achieve both (all comments with author's name) with clean format?

3 answers

This widget could not be displayed.

The variable you generate called "comments" is a list of objects, not a simple block of text.  It's one object per comment on the issue.  When you just splat it out into the result by saying comments.body, java is effectively taking a bit of a punt and assuming you want "recognisable text from the objects in this list"

What you need to do is iterate over the list, and pull what you need.  The pseudocode in my head is to replace comments.body with

  • Create a variable called something like results.  Needs to be able to hold a lot of text
  • for each $item in $comment {
    • add item.getUpdateAuthorFullName() to results 
    • add item.getUpdated() to results
    • add item.getBody() to results
    • add some separator string to results
    • }
  • And finally, return the results variable.

 

This widget could not be displayed.

@Nic Brough [Adaptavist] Since you are most active one that I know through the atlassion support tickets, can you please help?

This widget could not be displayed.

You can flexibly export comments to Excel with the Better Excel Plugin.

It represents comments with its own calculated fields concept, which doesn't require you actually creating custom fields in JIRA, just adding a couple of Groovy lines that define the value, type (numeric, text) and format (for numbers and dates) of the field.

Albeit you are welcome to create new calculated fields or modify the existing ones, these are available out of the box:

Excel commentsText, user and date of all comments.
It is a longer block of text that can be inserted into a single Excel cell. If you need only the first or last comments, and more granularity, see the next items.
Excel first commentText, user and date of the first (earliest) comment.
It is a block of text that can be inserted into a single Excel cell. If you need more granularity or better data types, see the next 3 items.
Excel first comment textThe actual text of the first comment.
Excel first comment userThe user who added the first comment.
Excel first comment dateThe date when the first comment was added.
Excel last commentText, user and date of the last (latest) comment.
It is a block text of that can be inserted into a single Excel cell. If you need more granularity or better data types, see the next 3 items.
Excel last comment textThe actual text of the last comment.
Excel last comment userThe user who added the last comment.
Excel last comment dateThe date when the last comment was added.

You should be able to achieve what you want with zero or little work.

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

215 views 3 0
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you