Multivaluelist control in TFS Work Item Tracking

Anisha Pindoria

One of the top asks from people in the field is to have the ability to have a dropdown in which you can select multiple values. Few people know that there is already a solution out on CodePlex, although it has its limitation. But it might be just good enough for what you are looking for.

Since the data is stored in the format “[value1];[value2]”, and the data is backed by a field that stores only 255 characters, you can quickly run into a character limit when have long values in the dropdown and/or select a lot of options. And because of this storage only limited query and reporting capabilities are available.

To enable the solution, you need to follow these three steps:

  1. Update your work item type definitions using witadmin or the process template editor.
  2. Install the control for TFS Web Access
  3. Install the control on all clients that run VS

In the blog post I will add a field called OS to list the different platforms a bug applies to.

Update your work items

Export the work item type “Bug” with the command

witadmin exportwitd /collection:http://<your server>:8080/tfs/defaultcollection /p:<your team project> /n:Bug /f:<your path>\Bug.xml

Open the exported Bug.xml file in notepad.

Locate the <FIELDS> section and add the field OS:

<FIELD name=”Platform” refname=”Microsoft.OS” type=”String”>
  <HELPTEXT>Platform bug was found on</HELPTEXT>
  <SUGGESTEDVALUES expanditems=”true”>
    <LISTITEM value=”[Vista]” />
    <LISTITEM value=”[Win7]” />
    <LISTITEM value=”[Win8]” />
    <LISTITEM value=”[All OS’s]” />
    <LISTITEM value=”[XP]” />
    <LISTITEM value=”[Win2K3]” />
    <LISTITEM value=”[Win2K8]” />
    <LISTITEM value=”[Win2K8 R2]” />
    <LISTITEM value=”[WP8]” />
    <LISTITEM value=”[Win8Svr]” />
  </SUGGESTEDVALUES>
</FIELD>

In the FORM section locate the control where the new field should be placed beneath. In this example, I want to place the control below the Iteration Path, so I search for <Control FieldName=”System.IterationPath”. Now paste the following text:

<Control FieldName=”Microsoft.OS” Type=”FieldControl” PreferredType=”MultiValueControl” Label=”OS” LabelPosition=”Left” />

It tells the system to use the MultiValueControl when it is available, but if a client does not have the control installed, it will fallback to the default FieldControl, which is the textbox.

Save the file and upload it to your server with the command

witadmin importwitd /collection:http://<your server>:8080/tfs/defaultcollection /p:<your team project> /f:<your path>\Bug.xml

Install control on Web Access

For the next step, you need to download the custom WIT controls from codeplex: http://witcustomcontrols.codeplex.com. Extract the downloaded zip, which should contain two files.

image

Go to the Extentions page in Web Access, which you find with the url: <a href="http://:8080/tfs/_admin/_extensions”>:8080/tfs/_admin/_extensions”>:8080/tfs/_admin/_extensions”>http://<yourserver>:8080/tfs/_admin/_extensions (or go to the Administration section, click on Control panel in the top navigation and choose the Extension hub).

image

Click Install and locate the file WitCustomControls.MultiValueControl.zip.

image

And click Enable.

Navigate to the Home page and create a new bug, and you will see the control:

image

Install control for Visual Studio

If a user has not installed the control on his machine (s)he will get the default dropdown, because we have used the PreferredType attribute

image

If you however run the msi that comes with the downloaded file from CodePlex, you will see the correct control in VS too.

image

When you have selected multiple options with the dropdown, users that have not installed the control are still able to modify the data

image

Final words

Although it has its limitations, it might be just good enough for you. If you are using our service (http://tfs.visualstudio.com) or don’t want to deal with the customization or the limitations, a good alternative good be to use the Tags that we have announced: http://blogs.msdn.com/b/bharry/archive/2013/01/30/announcing-visual-studio-2012-update-2-vs2012-2.aspx

0 comments

Discussion is closed.

Feedback usabilla icon