Skip to main content
Example scripts
arrow icon
To homepage
Jira
Data centre icon
Data Center

Display the Latest Comment Posted by the Currently Logged In User

Created 1 year ago, Updated 12 day(s) ago
App in script
ScriptRunner For Jira
ScriptRunner For Jira
by Adaptavist
Compatibility
compatibility bullet
Jira (8.5 - 8.22)
compatibility bullet
ScriptRunner For Jira (8.53.0)
Language |
groovy
import com.atlassian.jira.component.ComponentAccessor

def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def rendererManager = ComponentAccessor.rendererManager

def commentManager = ComponentAccessor.commentManager
def comments = commentManager.getComments(issue)

def filteredComments = comments.findAll {
    it.authorApplicationUser == loggedInUser
}

if (filteredComments) {
    def latestComment = filteredComments.last()
    rendererManager.getRenderedContent('atlassian-wiki-renderer', "${latestComment.authorApplicationUser.username}\n${latestComment.body}",
                                       issue.issueRenderContext)
}
Having an issue with this script?
Report it here