Import, export, and manage work item types
Updated: July 15, 2016
You can manage work item types for a team project by using the following witadmin commands:
destroywitd: Destroys a work item type, and destroys every work item of that type permanently without recovery.
exportwitd: Exports the definition of a work item type to an XML file, or to the Command Prompt window.
importwitd: Imports work item types from an XML definition file into a team project on a server that runs Team Foundation Server. If a work item type with the same name already exists, the new work item type definition overwrites the existing one. If the work item type does not already exist, this command creates a new work item type. To validate the XML that defines a work item type, but not import the file, you use the /v option.
listwitd: Displays the names of the work item types in the specified project in the Command Prompt window.
renamewitd: Changes the display name of a work item type within a specific project. After you run this command, work items of this type show the new name.
The witadmin command-line tool only works when run against an on-premises TFS. To run the tool, open a Command Prompt window where either Visual Studio or Team Explorer is installed and enter:
cd %programfiles(x86)%\Microsoft Visual Studio 14.0\Common7\IDE
On a 32-bit edition of Windows, replace %programfiles(x86)% with %programfiles%.
For more information about work item types, see Add type definitions for work items to a process template.
You can create and modify work item types by using Process Editor, a power tool for Visual Studio. This tool is not supported. For more information, see the following page on the Microsoft Web site: Team Foundation Server Power Tools.
For the team project where the work item types are defined, you must have the following permissions set:
To export or list work item types, you must be a member of the Project Administrators group or have your View project-level information permission set to Allow.
To destroy, import, or rename work item types, you must be a member of the Team Foundation Administrators security group or the Project Administrators security group.
For more information, see Permission reference for Team Foundation Server.
Even if you log on with administrative permissions, you must open an elevated Command Prompt window to perform this function on a server that is running Windows Server 2008. To open an elevated Command Prompt window, choose Start, open the shortcut menu for the Command Prompt, and then choose Run as Administrator. For more information, see the Microsoft Web site: User Access Control.
witadmin destroywitd /collection:CollectionURL /p:Project /n:TypeName [/noprompt]
witadmin exportwitd /collection:CollectionURL /p:Project /n:TypeName [/f:FileName] [/e:Encoding] [/exportglobalists]
witadmin importwitd /collection:CollectionURL [/p:Project] /f:FileName [/e:Encoding] [/v]
witadmin listwitd /collection:CollectionURL /p:Project
witadmin renamewitd /collection:CollectionURL /p:Project /n:TypeName /new:NewName [/noprompt]
Specifies the URI of the team project collection. The format for the URI is the following: http://ServerName:Port/VirtualDirectoryName/CollectionName
If no virtual directory is used, then the format for the URI is the following:
The team project for which the types of work items are to be managed. This team project must be defined in the project collection specified by the /collection parameter.
The /p parameter is required unless you run the importwitd command with the /v option.
The name of the work item type to destroy, export, import, or rename.
The path and file name of the XML definition file that contains the types of work items to be exported or imported. If you omit this parameter when you use the exportwitd command, the XML appears in the Command Prompt window.
The name of a .NET Framework 2.0 encoding format. The command uses the specified encoding to export or import the XML data. For example, /e:utf-7 specifies Unicode (UTF-7) encoding. If you omit this parameter, witadmin tries to detect the encoding, and if detection fails, witadmin uses UTF-8.
Exports the definitions of global lists referenced by the work item type. The definitions for global lists will be embedded into the work item type definition XML. When not specified, the definitions for global lists are omitted.
Validates the XML that defines the work item type, but does not import the XML definition file.
The new name of the work item type.
Disables the prompt for confirmation.
/? or help
Displays help about the command in the Command Prompt window.
When you use the destroywitd command, it destroys all the following objects:
The work item type
All work items of that type
Corresponding entries in the work item tables, the long text tables, and the link tables
Objects in the work item type metadata cache
Unless otherwise specified, the following values apply in each example:
URI for the team project collection: http://AdventureWorksServer:8080/tfs/DefaultCollection
Project name: AdventureWorks
Input or output file name: myworkitems.xml
Work item type name: myworkitem
Default encoding: UTF-8
The following command exports the definition for myworkitem to the file, myworkitems.xml.
witadmin exportwitd /collection:http://AdventureWorksServer:8080/tfs/DefaultCollection /p:AdventureWorks /f:myworkitems.xml /n:myworkitem
The following example exports the work item by using Unicode (UTF-7) encoding.
witadmin exportwitd /collection:http://AdventureWorksServer:8080/tfs/DefaultCollection /p:AdventureWorks /f:myworkitems.xml /n:myworkitem /e:utf-7
The following example exports the work item type and its referenced global lists.
witadmin exportwitd /collection:http://AdventureWorksServer:8080/tfs/DefaultCollection /p:AdventureWorks /f:myworkitems.xml /n:myworkitem /exportgloballists
The following example displays the definition of the work item type the Command Prompt window.
witadmin exportwitd /collection:http://AdventureWorksServer:8080/tfs/DefaultCollection /p:AdventureWorks /n:myworkitem
The following example imports the work item definition from the XML file.
witadmin importwitd /collection:http://AdventureWorksServer:8080/tfs/DefaultCollection /f:myworkitem.xml /p:AdventureWorks
A: You can add custom WITs and change the form layout. The Configure Features Wizard will update your team projects and you’ll get access to the latest features.
Changing the workflow or renaming a WIT might require you to perform some manual operations when updating your team project. To learn about which customizations you can safely make and which you should avoid, see Customize the work tracking experience: Before you customize, understand the maintenance and upgrade implications.
A: In Team Web Access, work items appear in query results and on the backlog and board pages of the Agile planning tools. To change the color associated with an existing WIT or add the color to use for a new WIT, edit the process configuration.
A: If you have a WIT that you want to retire, but maintain the work items that have been created based on that type, you can add a rule that disables all valid users from saving the work item type.
<TRANSITION from=" " to="New"> <FIELDS> <FIELD refname="System.CreatedBy"> <VALIDUSER not="[Team Project Name]Project Valid Users" /> </FIELD> </FIELDS> </TRANSITION>
If you want to restrict creation of a specific WIT to a group of users, there are two ways to restrict access:
Add the WIT to the Hidden Categories group to prevent the majority of contributors from creating them. If you want to allow a group of users access, you can create a hyperlink to a template that opens the work item form and share that link with those team members who you do want to create them.
Add a field rule to the workflow for the System.CreatedBy field to effectively restrict a group of users from creating a work item of a specific type. As the following example shows, the user who creates the work item must belong to the Allowed Group in order to save the work item.
<TRANSITION from=" " to="New"> <FIELDS> <FIELD refname="System.CreatedBy"> <VALIDUSER for="Allowed Group" not="Disallowed Group" /> </FIELD> </FIELDS> </TRANSITION>
A: To prevent team members from using a specific WIT to create a work item, you can remove it from the team project. When you use witadmin destroywitd, you permanently remove all work items that were created using that WIT as well as the WIT itself. For example, if your team doesn’t use “Impediment,” you can delete the WIT labeled “Impediment” from the Fabrikam Web Site project.
witadmin destroywitd /collection:"http://FabrikamPrime:8080/tfs/DefaultCollection" /p:"Fabrikam Web Site" /n:"Impediment"
When you delete a WIT that belongs to a category, you must update the categories definition for the team project to reflect the new name. In particular, the Agile planning tools will not work until you update the categories definition.
For more information, see Import and export categories.