Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Counting external comments when commenting on transition screen

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.

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events