I'm trying to store the latest comment in a custom field so that I can easily surface it in confluence. I'm on JIRA Cloud with SR.
How would I get the latest comment in an issue so that i can set it to a custom field in my ScriptRunner Listener that runs on Create and Update?
Thanks for the solution Vasiliy
Since I'm on Cloud, I had to go through the API.
To retrieve i used this call: /rest/api/2/issue/${issue.key}/comment
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
To get first or last comments (and more comment related fields) as a synchronised custom field you can also use the cloud App Comment Custom Fields for Jira.
The fields build at installation and will stay in sync from then on.
The answer is a bit late, but maybe someone else needs an easy scriptless solution
Disclaimer: I'm the product manager of said App.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You could use script field. Here is code to get last comment (test it before use):
import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.comments.Comment import com.atlassian.jira.issue.comments.CommentManager Issue issue CommentManager commentManager ; List<Comment> commentList = commentManager.getComments(issue) if(commentList.size() == 0) return null commentList.sort(new Comparator<Comment>() { @Override int compare(Comment o1, Comment o2) { if(o1.getCreated().before(o2.getCreated())) return -1 else return 1 } }) return commentList.get(0).getBody()
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.