Custom States values for Work Items in TFS 2010

In one of my previous blog posts I was asked how to add custom ‘State’ values for a work item in Team Foundation Server 2010. In this post I will look at how this can be achieved.


In one of my previous blog posts I was asked how to add custom ‘State’ values for a work item in Team Foundation Server 2010.

The state field is a unique field within the Work Item definition, and the mechanism to edit the values is not quite as intuitive as with other fields. Normally, the allowed values for a field are stored directly within the Field tag, using an AllowedValues (or even SuggestedValues) node:

<FIELD name=Priorityrefname=Microsoft.VSTS.Common.Prioritytype=Integerreportable=dimension>
  <HELPTEXT>Importance to business</HELPTEXT>
<ALLOWEDVALUES expanditems=true>
    <LISTITEM value=1 />
    <LISTITEM value=2 />
    <LISTITEM value=3 />
    <LISTITEM value=4 />
  <DEFAULT from=valuevalue=2 />

The State field is slightly different – the field definition itself doesn’t actually contain any of the valid state values:

<FIELD name=Staterefname=System.Statetype=Stringreportable=dimension>
  <HELPTEXT>Active = work remains to be done. Closed = tested and checked in.</HELPTEXT>

Instead, value state values are added to the States node within the Workflow node of the Work Item. See the below for adding a ‘Proposed’ state to the Work Item:

    <STATE value=”Proposed” />
    <STATE value=Active>
        <FIELD refname=Microsoft.VSTS.Common.ClosedDate>
          <EMPTY />
        <FIELD refname=Microsoft.VSTS.Common.ClosedBy>
          <EMPTY />
    <STATE value=Closed />

Transition rules can then be applied to the Work Item State using the Transitions node:

  <TRANSITION from=“” to=Proposed>
      <DEFAULTREASON value=New />
  <TRANSITION from=Proposedto=Active>

With these modifications made, you should now be able to re-import the Work Item Type definition file back into Team Foundation Server 2010.

C:\TFS>”C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\witadmin” importwitd /collection:localhost\defaultcollection /p:”{ExistingProjectName}” /f:Task.xml

Note – don’t forget to restart your Visual Studio environment before trying to use your updated Work Item in order to refresh the cache.

Author: Nick Hoggard

An architect working with the Microsoft development stack, my real interest lies in how we can utilise the tools we have to continuously improve our processes and quality.

4 thoughts on “Custom States values for Work Items in TFS 2010”

  1. Hello,

    I was trying to figure out a way to build a custom rule? I am creating a top level work item template, with n number of children possible. If all children items have a completed date value, I want to set the parent status to CLOSED else set it to a count of children records that are not closed. Example: OPEN – 7 child records remain open.

    Is this possible?

  2. Hi, thank you very much for this post – helped me out with my issue of creating new states for work items. Hopefully in the future there will be a easier way to modify the work flow and add states.

Leave a Reply

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

You are commenting using your 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 )

Google+ photo

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

Connecting to %s