You can now vote for scripts to help people know if they're useful or not. Login or create an account to vote!


Display the Latest Public Comment in a Text Field


This script copies the latest public comment from a Service Desk issue and displays it in a Text Field.


As a Service Desk Project Admin, I would like to get only the latest public comment in the issues displayed in a text field. In this script, when a comment is added to the issue, if it is a public comment, the script will copy it and update the text field with it.


  • Jira Service Desk Jira Service Desk (8.20 - 8.21)
  • ScriptRunner for Jira ScriptRunner for Jira (7.0.0)
import import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.event.issue.IssueEvent import com.atlassian.jira.event.type.EventDispatchOption import com.atlassian.jira.issue.MutableIssue import com.atlassian.jira.issue.comments.Comment import groovy.json.JsonSlurper final SD_PUBLIC_COMMENT = 'sd.public.comment' final textFieldName = '' def issue = event.issue as MutableIssue def issueEvent = event as IssueEvent def user = issueEvent.user def comment = issueEvent.comment def customFieldManager = ComponentAccessor.customFieldManager def issueManager = ComponentAccessor.issueManager def commentPropertyService = ComponentAccessor.getComponent(CommentPropertyService) def sampleMultiLine = customFieldManager.getCustomFieldObjectsByName(textFieldName).first() def isInternal = { Comment cmt -> def commentProperty = commentPropertyService.getProperty(user,, SD_PUBLIC_COMMENT).entityProperty.orNull if (commentProperty) { def props = new JsonSlurper().parseText(commentProperty.value) as Map props['internal'].toString().toBoolean() } else { null } } if (comment && !isInternal(comment)) { issue.setCustomFieldValue(sampleMultiLine, comment.body) issueManager.updateIssue(user, issue, EventDispatchOption.DO_NOT_DISPATCH, false) }
Discovered an issue? Report it here