In this blog, I will discuss on how we developed a new extension to address a long-standing user request for moving work items between projects in Azure DevOps (ADO) while retaining Test Case links. Many users, including myself, have faced challenges with this issue.
In an organization, we often work on multiple projects in ADO, and it's common to move work items like bugs and stories across projects related to different products. Generally, moving work items without Test Management items (such as Test Cases and shared steps) is straightforward, thanks to Microsoft's out-of-the-box functionality. However, moving work items that are linked to Test Management items has been problematic, as Microsoft does not provide built-in support for this scenario and throws error as below:
"VS403093: The work item xxxxx cannot be moved. Work items with links to Test Case work items cannot be moved. Please remove the work item link(s) and try again."
The new extension MoveworkitemExtension we have developed solves this problem.
Pre-Requisites:
- Add a new dropdown field named TargetProject with the reference name Custom.TargetProject.
- Populate this dropdown with all the project names in your organization, ensuring they match exactly.
After installing the extension, you'll see a "Move to Team Project" button enabled for all types of work items, except Test Cases. To move a work item with Test Case links, follow these steps:
- Select the target project from the dropdown and save the work item.
- Click the "Move to Team Project" button.
That's it! The work item, along with its Test Case links, will be moved to the selected project.
Idea Behind the Extension
Since directly moving work items with Test Case links isn't possible, our extension first unlinks the Test Cases from the work item. After unlinking, it updates the area path and iteration path of the work item to match the target project's area path. Once these updates are made, the extension relinks all the Test Cases to the work item, preserving their link types. Other links remain unchanged during this process.
For work items without Test Case links, the extension works similarly. Simply select the target project and click the "Move to Team Project" button. The area path and iteration path will be updated accordingly.
Permissions Needed
Lastly, you'll need specific permissions to perform this action.
- Move work items out of the project: This permission must be allowed in the source project for the user who wants to move the work item to another project.
- Create and edit work items: The user must have these permissions in the target project.
These permissions are also required when using Microsoft's out-of-the-box functionality, so they should be familiar to most users
Exceptions:
The process templates for both the source and target projects should be similar. They don't need to be identical or have the same fields, but the target project should not have any new mandatory fields. If the target project has any new mandatory fields while moving the item, an error message will be displayed.