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
I do something similar, and one difference that I note that may help you is that I set the type to LAX when defining the props object; the reason is that some, but not all, of the strings included in the JSON object are surrounded by quotes. I define props this way:
def props = new JsonSlurper().setType(JsonParserType.LAX).parseText(commentProperty.getValue())
Worth trying; it may solve your problem.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.