ScriptRunner: Last shared comment on issue

Joseph Hortch July 20, 2021

Hi, 

I am using the code below but I am having a hard time finding understanding how JIRA is separating comments by internal vs shared.  Any suggestions? 

/**
* Field name: LastComment
* Template: Text Field (multi-line)
*
* Description:
* Returns the last comment on an issue.
*
*/

import com.atlassian.jira.component.ComponentAccessor

 

// get the latest comment
def commentManager = ComponentAccessor.getCommentManager()
def comment = commentManager.getLastComment(issue)

// check to see if comments exist - return comment body if so
if (comment != null) {
return comment.body
}

return null

1 answer

0 votes
Ivan Lima
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 20, 2021

Hi @Joseph Hortch, you can get some insights into that through the Adaptavist Library script below. Have a look.

https://library.adaptavist.com/entity/get-the-visibility-of-new-comments-in-jira-service-desk

Joseph Hortch July 20, 2021

Hi Ivan, 

Thank you.  I will take a look. 

Suggest an answer

Log in or Sign up to answer