Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

Edited

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

0 votes

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"

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Apps & Integrations

Send an Email or Publish to Confluence - What should you do with your release notes?

Background When you hear the words ‘Release notes’, almost always you think of an unsolicited email from a software vendor. But I am here to tell you that from our data, sending release notes via E...

141 views 1 2
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you