Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,551,723
Community Members
 
Community Events
184
Community Groups

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
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Jun 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"

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events