You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
I have created a listener that counts external comments, but it does not count comments created in a transition screen. The listener gets triggered, but it seems that the comment is added after the listener is triggered.
//Count numbers of external comments
int externalCommentCount = 0
def commentManager = ComponentAccessor.getCommentManager()
def commentPropertyService = ComponentAccessor.getComponent(CommentPropertyService)
def comments = commentManager.getComments(event.getIssue())
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
comments.each { Comment comment ->
def commentProperty = commentPropertyService.getProperty(user, comment.id, "sd.public.comment").getEntityProperty().getOrNull()
if (commentProperty) {
def props = new JsonSlurper().parseText(commentProperty.getValue())
if (!props['internal'] || props['internal'] == 'false') {
externalCommentCount = externalCommentCount + 1
}
}
}
CustomFieldManager customFieldManager = ComponentAccessor.getComponent(CustomFieldManager)
Collection externalCommentsCountField = customFieldManager.getCustomFieldObjectsByName("External Comments Count")
def value = event.getIssue().getCustomFieldValue(externalCommentsCountField[0])
if (value != externalCommentCount) {
DefaultIssueChangeHolder changeHolder = new DefaultIssueChangeHolder()
externalCommentsCountField[0].updateValue(null, event.getIssue(), (Double) externalCommentCount, changeHolder)
}
If is update the issue afterwards, the comment added through the transition screen , gets added as a +1.