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!
Welcome to the community!
There's no way to set the status on creation. The create "transition" lands at one point in the workflow. It's a bit like a starting a railway journey, once you've bought a ticket and got on the train, the track ends at one fixed place and you can't change where it goes.
You'll need to do what you said - fast-track transition the issue after it's finished being created.
Thank you very much for your answer, Nic. Do you know why the method .setStatusId() even exists if every issue defaults to the first status of the associated worklflow, regardless of its value?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.