Hello,
i have the following problem,
i am trying to create a scripted Custom filed that do the following : the script field should shows true if the issue include a external comment and false if the issue doesn't include an external comment and it works but the problem is, when an old issue that includes very old external comments the script field doesn't show that the issue includes external comment
this is the script that i am using:
//comment id
final SD_PUBLIC_COMMENT = "sd.public.comment"
def commentManager = ComponentAccessor.commentManager
def commentPropertyService = ComponentAccessor.getComponent(CommentPropertyService)
def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser
// get whether the comment is internal or not, null means no property found, maybe not an SD issue
def isInternal = { Comment comment ->
def commentProperty = commentPropertyService.getProperty(user, comment.id, SD_PUBLIC_COMMENT)
.getEntityProperty().getOrNull()
if (commentProperty) {
def props = new JsonSlurper().parseText(commentProperty.getValue())
props['internal']
}
else {
null
}
}
// Example:all external comments on issue
//def issue = ComponentAccessor.getIssueManager().getIssueByCurrentKey("PROJ-1");
//log.debug commentManager.getComments(issue).findAll { !isInternal(it) }
if (commentManager.getComments(issue).findAll { ! isInternal(it) })
return "true"
else {
return "false"
}
Thanks