Joseph Michael Pesch
VP Programming

TFS Add Custom Work Item Type

by 5. January 2017 07:35

The easiest way to create a work item type is to copy an existing one, rename it, and then edit it. In the procedure below, you'll export the Feature work item type and use it as the basis for the Initiative work item type. Throughout the examples, the project name is Phone Saver, and the server name is Fabrikam. The team project collection name is the default name, DefaultCollection.

  1. Open a Command Prompt window in administrator mode and change directories to where Visual Studio (or Team Explorer) is installed.

                  cd %programfiles%\Microsoft Visual Studio 12.0\Common7\IDE
                

    On 64-bit editions of Windows, use %programfiles(x86)%.

  2. Use the witadmin tool to download the Feature work item type definition and save it as Initiative.xml.

                  witadmin exportwitd /collection:"http://fabrikam:8080/tfs/DefaultCollection" /p:"Phone Saver" /n:Feature /f:%userprofile%\documents\Initiative.xml
                
  3. Open the Initiative.xml file, replace <WORKITEMTYPE name="Feature"> with <WORKITEMTYPE name="Initiative">, and update the description.

                  <witd:WITD application="Work item type editor" version="1.0" xmlns:witd="http://schemas.microsoft.com/VisualStudio/2008/workitemtracking/typedef">
                  <WORKITEMTYPE name="Initiative">
                     <DESCRIPTION>Tracks an initiative that will be released with the product. </DESCRIPTION>
                
  4. Edit the Tab element labeled Implementation. Replace <Filter WorkItemType="Product Backlog Item" /> with <Filter WorkItemType="Feature" />. This will show features as children work items of initiatives.

                  <Tab Label="Implementation">
                   <Control Type="LinksControl" Name="Hierarchy" Label="" LabelPosition="Top">
                     <LinksControlOptions>
                        <LinkColumns>
                           <LinkColumn RefName="System.Id" />
                           <LinkColumn RefName="System.Title" />
                           <LinkColumn RefName="System.AssignedTo" />
                           <LinkColumn RefName="System.State" />
                        </LinkColumns>
                        <WorkItemLinkFilters FilterType="include">
                           <Filter LinkType="System.LinkTypes.Hierarchy" FilterOn="forwardname" />
                        </WorkItemLinkFilters>
                        <ExternalLinkFilters FilterType="excludeAll" />
                        <WorkItemTypeFilters FilterType="include">
                           <Filter WorkItemType="Feature" />
                        </WorkItemTypeFilters>
                     </LinksControlOptions>
                   </Control>
                  </Tab>
                
  5. Import the file.

                  witadmin importwitd /collection:"http://fabrikam:8080/tfs/DefaultCollection" /p:"Phone Saver" /f:%userprofile%\documents\Initiative.xml
                

Now that you have an Initiative work item type, you'll want to add a category for initiatives to the set of categories visible in the team project.

  1. Export the Categories definition to an xml file.

                  witadmin exportcategories /collection:"http://fabrikam:8080/tfs/DefaultCollection" /p:"Phone Saver" /f:%userprofile%\documents\categories.xml
                
  2. Open the file and add the Initiative category. Here's an example, where the Initiative category uses the company name to identify it as a customization:

                  <CATEGORY refname="Fabrikam.InitiativeCategory" name="InitiativeCategory">
                  <DEFAULTWORKITEMTYPE name="Initiative" />
                
  3. Just as you did before, import the file.

                  witadmin importcategories /collection:"http://fabrikam:8080/tfs/DefaultCollection" /p:"Phone Saver" /f:%userprofile%\documents\categories.xml
                

Now all that's left to do is to add your initiatives to the hierarchy of work items that make up the portfolio backlog.

  1. Export the process configuration definition to an xml file.

                  witadmin exportprocessconfig /collection:"http://fabrikam:8080/tfs/DefaultCollection" /p:"Phone Saver" /f:%userprofile%\documents\MyProcessConfiguration.xml
                
  2. Open the file and add a PortfolioBacklog section for Initiatives within the PortfolioBacklogs section. At the same time, modify the PortfolioBacklog element for FeatureCategory so that Initiatives will be parent work items for Features.

                  <PortfolioBacklogs>
                  <PortfolioBacklog category="Fabrikam.InitiativeCategory" pluralName="Initiatives" singularName="Initiative">
                  <AddPanel>
                  <Fields>
                  <Field refname="System.Title" />
                  </Fields>
                  </AddPanel>
                  <Columns>
                  <Column width="100" refname="System.WorkItemType" />
                  <Column width="400" refname="System.Title" />
                  <Column width="100" refname="System.State" />
                  <Column width="50" refname="Microsoft.VSTS.Common.BusinessValue" />
                  <Column width="100" refname="Microsoft.VSTS.Scheduling.TargetDate" />
                  <Column width="200" refname="System.Tags" />
                  </Columns>
                  <States>
                  <State type="Proposed" value="New" />
                  <State type="InProgress" value="In Progress" />
                  <State type="Complete" value="Done" />
                  </States>
                  </PortfolioBacklog>
                  <PortfolioBacklog category="Microsoft.FeatureCategory" parent="Fabrikam.InitiativeCategory" pluralName="Features" singularName="Feature">
                
  3. Add the color to use for Initiative to the WorkItemColors section.

                  <WorkItemColor primary="FFFF6600" secondary="FFFEB380" name="Initiative" />
                

    This assigns a bright orange color as the primary color to use in list displays, and a paler orange color to use on the task board and Kanban board.

  4. Import the file.

                  witadmin importprocessconfig /collection:"http://fabrikam:8080/tfs/DefaultCollection" /p:"Phone Saver" /f:%userprofile%\documents\MyProcessConfiguration.xml
                

And you're done! You‘ve added a third backlog level called Initiatives.

 

Reference source: https://msdn.microsoft.com/en-us/library/dn306083(v=vs.120).aspx

Tags:

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading