Hello,
The problem we are having is with a cloning issue. From now on, we have a script that will set new description on cloned issue. What we would like to achiev is that comments in original issue would be cloned either. Here is our script. The part with description works fine. Problem is with comments, there are no errors but comments won't show.
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
def issueManager = ComponentAccessor.getIssueManager()
def linkMgr = ComponentAccessor. getIssueLinkManager()
def result = "Original issue"
def commentManager = ComponentAccessor.getCommentManager()
def commentsList = commentManager.getComments(issue)
for (IssueLink link in linkMgr.getOutwardLinks(issue.id))
{
if( link.issueLinkType.name == "Cloners")
{
def newDescription = ("{color:red}Don't modify this description - edit the original (cloned) issue instead and the description gets copied here. {color}\n\n" + link.getDestinationObject().description) as String
issue.setDescription(newDescription)
issue.store()
result = "Branched issue"
for(def i = 0; i <= commentsList.size()-1; i++)
{
def comment = commentsList.get(i)
commentManager.create(issue,comment.getAuthorApplicationUser(),comment.getBody(),true)
issue.store()
}
}
}
return result
I am really looking forward for you answer.
Best regards,
Stanislava Caja.