Customising work item types in TFS2010

We recently examined our bug lifecycle at Mando Group, and one of the improvements we decided to implement was a simple categorisation so that we could report on the source of issues raised in Team Foundation Server. For example, some issues raised may be down to missing images which have not been added to the content management system, whereas others may be down to bona fide bugs in code. We wanted to be able to quantify these different issue types on each project.

New Global List

The first thing I did was take advantage of the Global List feature in TFS2010 (see this MSDN article on managing global lists) to set up the list of classifications we wanted to use across all projects. (nb I’ve shortened the listitem elements for brevity)

I placed the following XML in a local file (eg c: DefectCategories.xml)

<?xml version="1.0" encoding="utf-8"?>
<gl:GLOBALLISTS xmlns:gl="http://schemas.microsoft.com/VisualStudio/2005/workitemtracking/globallists">
<GLOBALLIST name="Mando – DefectCategories">
<LISTITEM value="Bug" />
<LISTITEM value="Content missing or incorrect" />
<LISTITEM value="Duplicate" />
</GLOBALLIST>
</gl:GLOBALLISTS>

From the VS2010 cmd prompt run the following command

witadmin importgloballist /collection:http://yourtfsdomain.com:8080/tfs/yourcollection /f:"c:DefectCategories.xml"

To confirm the global list has been added correctly, run this command and verify that the global list is present in the output:

witadmin exportgloballist /collection:http://yourtfsdomain.com:8080/tfs/yourcollection

Note that once the Global List has been created, items can be added to it using the Process Editor in the TFS power tools (see http://stackoverflow.com/questions/3507974/adding-items-to-a-global-list-in-tfs-via-the-sdk)

Modify the WorkItem Type on your Project

This step shows how to implement the global list categorisation on a bug work item type on a specific project. If you choose to, you can make similar changes to other work item types, and also it is possible to change the process template XML so that the change applies to all projects subsequently created from this template. These options are outside the scope of this article.

What we’re doing here is adding a new field which references the Global List, so that the values are limited to those available in the Global List, and a new control in the bug layout so that we have a drop-down to choose the value in the UI. Importantly, we’re also adding an extra step in the bug workflow which means that the categorisation is mandatory at the point the bug is being closed.

First export the bug work item definition from the project you wish to amend it for. The example below exports the Bug work item type from the “YourProject” project in the ‘yourcollection’ to a file called “bug.xml”:

witadmin exportwitd /collection:http://yourtfsdomain.com:8080/tfs/yourcollection/ /p:YourProject /n:Bug /f:"c:bug.xml"

Open the XML file for the bug in a text editor (Visual Studio or NotePad is fine) and make the following changes:

1. At the end of the FIELDS element add the new field as follows:

<FIELD name="Mando Classification" refname="Mando.Classification" type="String" reportable="dimension">
<ALLOWEDVALUES>
<GLOBALLIST name="Mando – DefectCategories" />
</ALLOWEDVALUES>
<HELPTEXT>This categorisation allows reports to be generated to establish the cause of bugs</HELPTEXT>
</FIELD>

2. Find the STATE element which has the value attribute of “Closed”. Within this element, ensure the classification is mandatory as part of the workflow by including this as a required field:

<STATE value="Closed">
<FIELDS>
 <FIELD refname="Mando.Classification">
<REQUIRED />
</FIELD>
</FIELDS>
</STATE>

3. Within the Layout element, find the Classification group and add a control to represent the classification so it can be set by users in Visual Studio (note that the control group you add it to is up to you, and your XML may look different depending on which process template you’re using):

<Group Label="Classification">
<Column PercentWidth="100″>
<Control FieldName="System.AreaPath" Type="WorkItemClassificationControl" Label="&amp;Area:" LabelPosition="Left" />
<Control FieldName="System.IterationPath" Type="WorkItemClassificationControl" Label="Ite&amp;ration:" LabelPosition="Left" />
<Control FieldName="Mando.Classification" Type="FieldControl" Label="Defect Classification" LabelPosition="Left" />
</Column>
</Group>

Lastly you need to import the updated XML bug definition into TFS

witadmin importwitd /collection:http://yourtfsdomain.com:8080/tfs/yourcollection/ /p:YourProject /f:"c:bug.xml"

Don’t forget to update the project name and filename parameters for your own project.

There are other approaches to making these changes, including the more visual approach in the WIT designer (TFS power tools). I took the XML modification approach for better consistency between projects.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: