Hi,
I am trying to migrate my projects to a new workflow scheme, which has an updated Sub-Task workflow.
I have specified old status : new status mapping in the script. But, despite this, post migration, the sub-tasks are not working as expected (Though they are in the new workflow, they are behaving odd , like unable to move them through any status). We have used this same script to migrate other issue types without problem. Any thoughts on what we might be missing, or should sub-tasks be dealt differently ?
Here is a snippet of the logic,
def subtaskMapping = [ "old" : "new" ]
JiraWorkflow subTaskWF = workflowManager.getWorkflow("New Sub Task Worklow")
projectkeys.each { projectKey ->
def project = ComponentAccessor.projectManager.getProjectObjByKey(projectKey as String)
def oldWFScheme1 = ComponentAccessor.WorkflowSchemeManager.getWorkflowScheme(project)
def oldWFScheme = oldWFScheme1?.name ? oldWFScheme1.name: ""
def source
if (oldWFScheme == "XYZ Workflow Scheme") {
source = ComponentAccessor.projectManager.getProjectByCurrentKey("TEST") //source project with new scheme
}
if(source){
if(project){
def issues = ComponentAccessor.issueManager.getIssueObjects(ComponentAccessor.issueManager.getIssueIdsForProject(project.id));
issues.each{issue ->
if(issue.getIssueType().getName() == "Sub-Task"){
def oldStatus =issue.getStatus().getName()
def newStatus = subtaskMapping[oldStatus]
if(newStatus){
Status destinationStatus = constantsManager.getStatusByNameIgnoreCase(newStatus);
workflowManager.migrateIssueToWorkflow(issue as MutableIssue, subTaskWF, destinationStatus)
}
ComponentAccessor.getWorkflowSchemeManager().removeSchemesFromProject(project);
ComponentAccessor.getWorkflowSchemeManager().addSchemeToProject(project, ComponentAccessor.getWorkflowSchemeManager().getSchemeFor(source))