Third Shelf

Customising Work Item Templates

Posted in team foundation server, visual studio by Sydney du Plooy on October 26, 2008

Making use of either Team System Web Access or Team Explorer you might find it necessary to edit some of the work item templates. At first it might seem very confusing but is quite straight forward.

When editing work item templates there are two tools that you need to know about, witimport and witexport. They are used to import and export specific work item templates from an existing Team Foundation Server project.

First, you need to export the bug work item template by using the following command line:

witexport /f <work item templates folder>
    /t <tfs server>:8080 /p <project name> /n bug

This will create a bug.xml template file in the work item templates folder specified, which could be any folder that you have access to.

The first part of the XML file defines the fields (indicated by the fields tag) that describe the bug. A workflow process (indicated by the workflow tag) is described in the middle of the file and the bottom part of the file describes the layout (indicated by the form tag) of the bug submission form.

Let’s add an environment field to the template that will indicate the environment where the bug occurred with the following values, tip, pre-stage, stage and live:

<field name="Environment" refname="TfsProject.Environment" type="String">
    <required />
    <helptext>Was the bug found in tip, pre-stage, stage or live?</helptext>
    <allowedvalues>
	<listitem value="Tip"/>
	<listitem value="Pre-stage"/>
	<listitem value="Stage"/>
	<listitem value="Live"/>
    </allowedvalues>
    <default from="value" value="Pre-Stage"/>
</field>

The above piece of XML can be put anywhere after a closing field tag or the opening fields tag and must be somewhere before the workflow opening tag.

Name is obviously the name of the field that we are giving the additional piece of information. RefName is the name of this field that we are going to use to refer to when setting up the control in the layout section of the file. The presence of required tag says that a value must be specified for this field and will be validated automatically when a new bug is submitted. Next, we supply a list of values that will appear in the drop down list. Finally we provide a default value that will automatically be selected for each bug submission.

We now have to specify the new look of the form with our additional field and is done with the following XML definition:

<group>
    <column PercentWidth="50">
        <control Type="FieldControl" FieldName="TfsProject.Environment" Label="&Environment:" LabelPosition="Left" />
    </column>
    <column PercentWidth="50">
        ...
    </column>
</group>

A group defines a collection of controls that are related. The column tag has an attribute that states the percentage space that the control should occupy. Each group should add up to to 100% but do not have to. The fieldname should be set to the field that we have just created in the fields section of the template. The label attribute is set to the label that we want to show in front of the control. In this case it is “Environment:”.

After placing the control, all that is left is to save the bug.xml file and import it back into Team Foundation Server. This is accomplished by the following command line:

witimport /f <work item templates folder>\bug.xml
    /t <tfs server>:8080 /p <project name>

After a successful import the changes should be visible from both TSWA (Team System Web Access) and Team explorer, by double clicking on the Bug work item template.

Go customise those work item templates!

Tagged with: , ,

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

Follow

Get every new post delivered to your Inbox.

Join 144 other followers