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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Copy Comment Other Project

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

1 answer

1 accepted

0 votes
Answer accepted
Hana Kučerová Community Leader Jul 30, 2020

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...

Hana ,

Very well thank you!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Site Admin
TAGS
Community showcase
Published in Jira Service Management

Why upgrade to Jira Service Management Premium?

We often have questions from folks using Jira Service Management about the benefits to using Premium. Check out this video to learn how you can unlock even more value in our Premium plan.  &nb...

165 views 0 4
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you