Hello All,
How to display all comments in custom email using script runner.
Thanks in advance,
Bunty
Weird... I though I already posted the answer, now that I check it doesnt show up.
Here
<%def commentManager = com.atlassian.jira.component.ComponentAccessor.getCommentManager()def comments = commentManager.getComments(issue)for(comment in comments){out << comment.body + "\n"}%>
This should return all comments of an issue
def commentManager = ComponentAccessor.getCommentManager()def comments = commentManager.getComments(sourceIssue)
Hi Gezim,
Thanks for the reply.
Does the script work in Email Template to retrieve all comments?
Currently, i am using below script in Custom Email template in post function to display last comment in Email:
<% (transientVars?.comment)out << transientVars.comment%>
In that case $comments.body - will return a list of strings (comment bodies)
Thanks Shehu. It worked but it not in sequence all comments in one line.
Is it possible to restive date and time like sequence in the below:
@Bunty in that case you can use something like this
"<% %>" allows you to escape the GString template and run native Groovy code.
PS I'm writing in a separate answer, so this can be marked as accepted.
Cheers
Thanks Shehu. It is working and i can see comments in sequence.
Sorry, I am new to scripting so i am confused in making changes to script.
One last question, can we retrieve author name and date in comments?
Thanks again,
Manikanta
Glad to help.
Sure, to display the author you could use
<%def commentManager = com.atlassian.jira.component.ComponentAccessor.getCommentManager()def comments = commentManager.getComments(issue)for(comment in comments){out << "Comment by: " + comment.getAuthorApplicationUser().getDisplayName() +"\n"out << comment.body + "\n"}%>
Hi Shehu,
able to get the comments but all the comments getting in single line by using below
example: getting like this
Comment1 comment2 comment 3
But i want every comment in next line as below
Comment1
Comment2
Comment 3
Kindly help on this
@Gezim Shehu [Communardo]
Please can you guide me on above , all the comments should get in next Line
Regards,
Sandhya
It looks like you're new here. Sign in or register to get started.