Is there any way to do this with script?
I am constantly getting error that it is not possible in the current state, even though I'm in the Open step. I have tried with reindexing issue after creation as well.
ApplicationUser currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issue = event.getIssue()
def reporter = issue.getReporter()
def upm = ComponentAccessor.getUserPropertyManager()
def propertySet = upm.getPropertySet(reporter)
if(propertySet.getString("jira.meta.Spam").equals("true")){
def workflowManager = ComponentAccessor.getWorkflowManager()
IssueService issueService = ComponentAccessor.getIssueService()
JiraWorkflow jiraWorkflow = workflowManager.getWorkflow(issue)
def issueIndexService = ComponentAccessor.getComponent(IssueIndexingService)
StepDescriptor oStep = jiraWorkflow.getLinkedStep(issue.getStatus());
List<ActionDescriptor> oActions = oStep.getActions();
for(ActionDescriptor oAction : oActions){
if(oAction.getName().equals("Spam")){
IssueInputParameters issueInputParameters = issueService.newIssueInputParameters()
def validationResult = issueService.validateTransition(currentUser, (Long) issue.getId(), oAction.getId(), issueInputParameters)
log.warn validationResult.getErrorCollection()
if(validationResult.isValid()){
issueService.transition(currentUser,validationResult)
}
}
}
}
This works well for issue updated event, just not on create.