I use the following snippet of code to automatically close an issue when it meets some conditions:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.util.JiraUtils
import com.atlassian.jira.workflow.WorkflowTransitionUtil
import com.atlassian.jira.workflow.WorkflowTransitionUtilImpl
int transitionId = 31
def issueManager = ComponentAccessor.getIssueManager()
def util = (WorkflowTransitionUtil) JiraUtils.loadComponent(WorkflowTransitionUtilImpl.class)
def mutableIssue = issueManager.getIssueObject(issue.getKey())
util.setIssue(mutableIssue)
util.setUserkey("admin@company.com")
util.setAction(transitionId)
util.progress(
I put in a custom Event Listener script. The snippet does not work when the event is Issue Created. It reports no error, just does not change the status into the one I specified. If I change the event to Issue Assigned or Issue Commented, it works as expected.
Is Issue Created fired before or after the issue was actually created in Jira?