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
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
I would to answer with an generic account in my service Desk. But I want to know who make the answer in internal.
I use the script Listeners and the event : ServiceDeskCommentEvent
The script must to do :
Verify if account is service Desk
Verify if answer is for customer (external)
Delete the last comment
Write internal comment with the current user
Write external comment with generic account of service Desk
I do all of that if I know the Issue number. (with getIssueByCurrentKey() )
Now I would to do this with all issues when the event is trigerring. But it's not working with issueEvent.getIssue().
I need this kind of function for all events on Issues comments
Thanks
import com.atlassian.crowd.embedded.api.Group
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.issue.comments.CommentManager
import com.atlassian.jira.issue.comments.MutableComment
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.util.json.JSONObject
import com.atlassian.jira.bc.issue.comment.property.CommentPropertyService
import com.atlassian.jira.issue.comments.Comment
import groovy.json.JsonSlurper
final SD_PUBLIC_COMMENT = "sd.public.comment"
CommentManager commentManager = ComponentAccessor.getCommentManager()
//def issue = issueEvent.getIssue()
//def issue = ComponentAccessor.getIssueManager().getIssueByCurrentKey("I-01")
def groupManager = ComponentAccessor.getGroupManager()
ApplicationUser supportUser = ComponentAccessor.getUserManager().getUserByName("ahl")
ApplicationUser currentUser = commentManager.getLastComment(issue).authorApplicationUser
MutableComment mutableCommentSupport = (MutableComment) commentManager.getLastComment(issue)
def comment = commentManager.getLastComment(issue)
def commentPropertyService = ComponentAccessor.getComponent(CommentPropertyService)
def isInternal = { Comment c ->
def commentProperty = commentPropertyService.getProperty(currentUser, c.id, SD_PUBLIC_COMMENT).getEntityProperty().getOrNull()
if (commentProperty) {
def props = new JsonSlurper().parseText(commentProperty.getValue())
props['internal']
}
else {
null
}
}
if (comment) {
if(isInternal(comment) == false) {
//Properties
def properties = [(SD_PUBLIC_COMMENT): new JSONObject(["internal": true] as Map)]
if (['Hotline','jira-servicedesk-users'].any {groupManager.isUserInGroup(currentUser, it)}){
if(currentUser != supportUser) {
//delete original comment
commentManager.delete(commentManager.getLastComment(issue))
//External comment
commentManager.create(issue, supportUser, mutableCommentSupport.body, false)
//Internal comment
commentManager.create(issue, currentUser, mutableCommentSupport.body, null, null, new Date(), properties, false)
}
}
}
}