Hello everybody,
I'm currently working on a script which automatically creates a story with subtasks on the first day of each month. I'm almost done with it, but I've noticed that I can't set the status of an issue upon creation. No matter what statusId I set as a parameter, the status of the created issues are always set to the default status (the first status in the workflow after creation). So for example, I'm trying to create an issue which upon creation has the status "to Do", but the issue is always set to "Backlog" (first status in the workflow).
relevant code:
def issueStatusId = "11"
def issueInputParameters_parent = issueService.newIssueInputParameters()
issueInputParameters_parent.with {
projectId = projectManager.getProjectObjByKey(projectKey).id
summary = summaryDesc
issueTypeId = issueTypeNameId
reporterId = reporterNameId
assigneeId = assigneeNameId
description = descriptionText
statusId = issueStatusId
priorityId = priority_high.id
}
def validationResult = issueService.validateCreate(user, issueInputParameters_parent)
assert !validationResult.errorCollection.hasAnyErrors()
def issueResult = issueService.create(user, validationResult)
log.info "Issue created: ${issueResult.issue}"
I've also tried setting the status like this:
issueInputParameters_parent.setStatusId("11")
But this returns the same result.
I'm aware that I can transition the issue status after creation, but I'd like to set the correct one right at creation, since my spaghetti code is already long enough.
Any help is greatly appreciated!