The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

LastComment Scripted Field no longer works in Jira 8 (ScriptRunner 5.5.7.1)

Christopher Gronde
Contributor
June 24, 2019

We have a commonly used script runner field called Last Comment that no longer works after our most recent update to Jira. 

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)
def date = comment.getCreated()

return ((date as String) + " " + comment.body + "<br> Author: " + comment.authorFullName)

 We have already discovered that the first import no longer works and must be replaced with

import com.atlassian.jira.component.pico.ComponentManager

But that breaks other parts of the code.  Can anyone help with the new code or where to find what needs changed?

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
PD Sheehan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
June 25, 2019

While I don't have Jira 8 yet ... the ComponentManager has been deprecated for a long time.

And you don't seem to be using it anywhere in your script. Probably just some leftover.

I suspect the following simplified script will work just fine with identical results:

import com.atlassian.jira.component.ComponentAccessor
def comment = ComponentAccessor.commentManager.getLastComment(issue)
"$comment.created $comment.body <br> Author: $comment.authorFullName"
TAGS
AUG Leaders

Atlassian Community Events