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"
}
%>
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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"
}
%>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Bunty in that case you can use something like this
<%
def commentManager = com.atlassian.jira.component.ComponentAccessor.getCommentManager()
def comments = commentManager.getComments(issue)
for(comment in comments){
out << comment.body + "\n"
}
%>
"<% %>" 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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Shehu,
able to get the comments but all the comments getting in single line by using below
<%
def commentManager = com.atlassian.jira.component.ComponentAccessor.getCommentManager()
def comments = commentManager.getComments(issue)
for(comment in comments){
out << comment.body + "\n"
}
%>
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please can you guide me on above , all the comments should get in next Line
Regards,
Sandhya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This should return all comments of an issue
def commentManager = ComponentAccessor.getCommentManager()
def comments = commentManager.getComments(sourceIssue)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
%>
Thanks in advance,
Bunty
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In that case $comments.body - will return a list of strings (comment bodies)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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:
Thanks in advance,
Bunty
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.