Hi,
I'm wanting the comments made on a Sub-Task to appear on the parent ticket. I'd like this to happen for each comment that is made on the sub-tasks.
I've heard tell that using a script in scriptrunner will do this and found this page which seems to give some information but I'm getting errors when I put this into scriptrunner: I ignore this (rightly or wrongly) and save it, but nothing happens when I add comments to sub-tasks. Even one I have created AFTER adding this in.
Can anyone see what I'm doing wrong?
For reference the whole script that I'm adding in is:
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.event.issue.AbstractIssueEventListener
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.comments.Comment
import com.atlassian.jira.issue.comments.CommentManager
import org.apache.log4j.Category
class SubtaskCommentListener extends AbstractIssueEventListener {
Category log = Category.getInstance(SubtaskCommentListener.class)
CommentManager commentManager = ComponentManager.instance.commentManager
@Override
void workflowEvent(IssueEvent event) {
// only one central way...
this.customEvent(event)
}
@Override
void customEvent(IssueEvent event) {
// set explicit to debug
log.setLevel(org.apache.log4j.Level.DEBUG)
log.debug "Event: \"${ComponentManager.instance.eventTypeManager.eventTypesMap[event.getEventTypeId()].name}\" fired for ${event.issue}"
// Here you should put any subtask based restrictions for this task like
// only for special subtask issue types or similar
Comment comment = event?.getComment()
if (comment && event.issue.isSubTask()) {
log.debug "New commment for subtask found."
Issue parent = event.issue.getParentObject()
// Here you should put any parent task based restrictions like
// only for special issue types or similar
commentManager.create(parent, comment.author, comment.updateAuthor, comment.body, comment.groupLevel, comment.roleLevelId, comment.created, comment.updated, true, true)
log.debug ("Created comment on ${parent.key}")
}
}
}
Thanks,
Hi,
It seems there's a problem whilst you try to initialize 'commentManager' variable.
Try the following:
First add this import:
import com.atlassian.jira.component.ComponentAccessor
Then replace this line:
CommentManager commentManager = ComponentManager.instance.commentManager
with this:
CommentManager commentManager = ComponentAccessor.getCommentManager()
Thanks for the reply, I've done all of that and still nothing is showing on the parent task?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.