Copy sub-task comment to parent Edited

After a sub-task is transitioned from OPEN to APPROVED, the user is prompted to add a comment. I have a post function that should grab that comment (I'm using getLastComment because I anticipate only one comment for now), and post a new comment with the same body text to that sub-task's parent.

Here's the script I'm using ... 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue 
import com.atlassian.jira.issue.comments.CommentManager

Issue parentIssue = issue.getParentObject()

def feedback = ComponentAccessor.commentManager.getLastComment(issue)

if (feedback) {
	create(parentIssue, feedback.getAuthorApplicationUser(), feedback.getBody(), true)
}

... which gives me the following error:

2017-05-16 14:44:44,314 ERROR [workflow.ScriptWorkflowFunction]: *************************************************************************************
2017-05-16 14:44:44,314 ERROR [workflow.ScriptWorkflowFunction]: Script function failed on issue: ITCM-327, actionId: 11, file: <inline script>
groovy.lang.MissingMethodException: No signature of method: org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.create() is applicable for argument types: (com.atlassian.jira.issue.IssueImpl, com.atlassian.jira.user.DelegatingApplicationUser, java.lang.String, java.lang.Boolean) values: [ITCM-326, ewinter(ewinter), here's a comment, true]
Possible solutions: grep(), iterator()
	at Script181.run(Script181.groovy:10)

Any ideas why this might be occurring? If I understand the error log correctly, one of the arguments I'm passing to create() is the wrong type, but I can't figure out which.

Thanks in advance.

1 answer

1 accepted

I figured it out. I was supposed to be using: 

ComponentAccessor.getCommentManager().create( ... )

instead of just create( ... ).

 

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published yesterday in Marketplace Apps

Tips on how to choose the best estimation method for your planning

Planning and grooming sessions all come with their own sets of rules. Team members meet to estimate stories or other work items, all according to an agreed-upon process. And with every session comes ...

64 views 0 11
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you