As an exemple:
I’m starting from a workflow with only “To do”, “In progress”, “Done” and i want to add a status named “Analysis” and a transition from “Done” to “Analysis”.
I bases my code on this kb : https://community.developer.atlassian.com/t/create-workflow-through-java-api/4232
It’s very close to what i want to do but, for now, i’m focused on the transition.
Here’s my code :
def workflowManager = ComponentAccessor.workflowManager; def constantManager = ComponentAccessor.constantsManager; ActionDescriptor action = DescriptorFactory.getFactory().createActionDescriptor(); action.setName("To Analysis") ResultDescriptor result = DescriptorFactory.getFactory().createResultDescriptor(); Status newStatus = constantManager.getStatusByName("Analyse"); Status oldStatus = constantManager.getStatusByName("Done"); JiraWorkflow workflow = workflowManager.getWorkflow("MyWorkflow"); result.setStep(workflow.getLinkedStep(newStatus).id); result.setOldStatus("Done"); result.setStatus("Analyse"); action.setParent(workflow.getLinkedStep(oldStatus)); action.setUnconditionalResult(result) workflow.getLinkedStep(oldStatus).getActions().add(action)
The result is a totally unexpected.
Actually i have my transition between “Analysis” and “Done” but it had no name. I tried to use :
ActionDescriptor transition = new ActionDescriptor().setName();
With no success.
Besides the most incredible things is that i cannot access to my workflow anymore through the project settings or through admin > issue > workflow. I can only saw it from “Display workflow” in the issues of the project.
When i try to access from settings (project or admin) i get a 404 or a 500 error.
How can i have access to that workflow again ? (besides i can’t delete it either)
How can i do a pretty transition that doesn’t ruin my workflow ? I would also like to know if it’s possible to do one transition that like all statuses of the workflow to one, in one line of code.