Attempting an alternate solution to my post here: https://community.atlassian.com/t5/Jira-questions/Add-a-status-to-a-workflow-programmatically-com-atlassian-jira/qaq-p/2178063
We are going through a conversion (of 1,000s of projects) from Simplified Workflow to Fixed Workflows. The challenge is we have one issue type where we want to maintain existing statuses that have been defined on the board.
In my other post I describe the issue with attempting to "add" a status to a workflow (using com.atlassian.jira.workflow.edit.WorkflowStatuses). Alternatively, I have tried taking a copy of the original simplified workflow with all the statuses and then deleting any steps related to statuses no longer necessary.
WHAT WORKS:
Using ProjectRapidViewService.findRapidViewsByProject I retrieve all the boards for the project. From there I create a list of statuses to keep. I then use ComponentAccessor.workflowManager.copyWorkflow to create a copy of the simplified workflow.
- I have tried WorkflowManager getLinkedStatusObjects to get all the statuses and for the ones to remove getLinkedStep(thisSTATUS) to get the StepDescriptor.
- Alternatively I also have tried WorkflowManager getAllActions() to loop through actions and getStepsForTransition and for matching step status getting the StepDescriptor
WHAT DOESN'T WORK:
In both cases, with a valid StepDescriptor the removeStep(StepDescriptor) fails with the message
- "message":"Cannot remove step - it is a destination step of at least one transition."
The documentation indicates it should reply with a boolean (true if the remove was successful) but when it fails it stops execution and throws this error.
How can I remove the step and/or status from the workflow in the case of ?