Hello Jan:
In this question you will find an asnwer on how to get a comment from an Issue Object. Afterwards you can iterate to find the latest one, or find the one with the latest date.
If this doesn't work for you, let us know and I'll program a 1 on 1 meeting with you to get it working.
Cheers!
Put below code under custom "scripted field"
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)
comment.body
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Tukaram,
is it possible to add user name who commented on this along with comment?.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes , use below code
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)
comment.body + " Author: " + comment.authorFullName
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you, Tukaram.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
First of all thank you, however how can I add error handling on it? when an issue is created the field starts throwing up a lot of error messages in the logs as there is no comment yet.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try below one
def comment = commentManager.getLastComment (issue)
if(comment != null)
{
comment.body + " Author: " + comment.authorFullName
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I can't see a scripted field option? How do I make this work with a Script Listener to populate a custom field I made called: "Last Comment"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
this worked great for me. is there a way to break up the "+ comment.authorFullName" to just show first name instead of 'last,first' ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Just want to see is there way to show the last comment without any inline images in the comment body? Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is it possible to have this script only show the last comment of the reporter or the assignee ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Small update
Replace
import com.atlassian.jira.ComponentManager
with
import com.atlassian.jira.ComponentAccessor
import com.atlassian.jira.ComponentAccessor
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)
comment.body
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, Any idea if and how can I re-render the wiki style render ?
Lots of comments contain formatting and user mentions , new lines, bullets are not formatted at all.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try this, it works but i found that my Database usage spiked after using it.
https://community.atlassian.com/t5/Jira-questions/Scripted-Field-to-copy-latest-comment/qaq-p/51850
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.