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.
Hi,
I clone the records opened on the jira service desk to the software project. I copy the comments with the Listener feature (comment event). There is no problem in the outward part, but I do not copy the comments to the software project as inward. Does anyone have any suggestions?
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.comments.MutableComment;
import com.atlassian.jira.issue.comments.CommentManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.user.ApplicationUser;
CommentManager commentMgr = ComponentAccessor.getCommentManager()
ApplicationUser currentUser = ComponentAccessor.getJiraAuthenticationContext().loggedInUser
//IssueManager im = ComponentAccessor.getIssueManager();
//MutableIssue issue = im.getIssueObject("YAZ-2")
def issue = event.issue
def lastComment = commentMgr.getComments(issue).last().body
//def links = ComponentAccessor.getIssueLinkManager().getInwardLinks(issue.getId())
def links = ComponentAccessor.getIssueLinkManager().getOutwardLinks(issue.getId())
//return links[0].getSourceObject()
def output = ""
for(l in links) {
// Outward Linki için kullanıyoruz
output = output + l.issueLinkType.name + ": " + l.getDestinationObject() + "<br/>"
// Inward Linki için kullanıyoruz
//output = output + l.issueLinkType.name + ": " + l.getDestinationObject() + "<br/>"
commentMgr.create(l.getDestinationObject(), currentUser, lastComment, false)
}
//return output
Hi @Ufuk Uysal ,
please, try something like this:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.comments.Comment
import com.atlassian.jira.issue.comments.CommentManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.issue.link.IssueLinkManager
import com.atlassian.jira.user.ApplicationUser
Issue issue = event.issue
Comment comment = event.comment
CommentManager commentManager = ComponentAccessor.getCommentManager()
IssueLinkManager issueLinkManager = ComponentAccessor.getIssueLinkManager()
ApplicationUser loggedInUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
String commentBody = comment.getBody()
issueLinkManager.getOutwardLinks(issue.getId()).each {IssueLink issueLink ->
commentManager.create(issueLink.getDestinationObject(), loggedInUser, commentBody, false)
}
issueLinkManager.getInwardLinks(issue.getId()).each {IssueLink issueLink ->
commentManager.create(issueLink.getSourceObject(), loggedInUser, commentBody, false)
}
I think the problem is in mixture of outward/inward links and destination/source objects...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Hana Kučerová I have a similar request. Can you help me with the code for Cloud? I tried the above code and it is saying "Invalid Imports". Mine is a Cloud instance
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @SriYarr ,
I recommend you to create a new question, the solution will be different for cloud.
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.