Automatically append some generated comment on a transition.

In this case we add a comment if a user resolved an issue which had unresolved subtasks:

import com.atlassian.jira.component.ComponentAccessor

def commentManager = ComponentAccessor.getCommentManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getUser()

if (issue.subTaskObjects.any { ! it.resolutionObject }) {
    commentManager.create(
        issue,
        user,
        "I resolved this issue even though there were unresolved sub-tasks... slapped wrists",
        false) (1)
}
1 change false to true in order to raise an IssueCommented event for notifications

For how-to questions please ask on Atlassian Answers where there is a very active community. Adaptavist staff are also likely to respond there.

Ask a question about ScriptRunner for JIRA, for for Bitbucket Server, or for Confluence.