Using TFS Kanban Column State to the warehouse


For a while I have been wondering and querying if it is possible to see or use the customizable Kanban columns in the warehouse for reporting purposes. The answer many times come up as no. Having done a lot of customisation of TFS lately I decided to take a stab at it.

Below is my solution for getting the Kanban column state into the warehouse.

Customise

First you’ll need to add a custom field to a Work Item Type, in a previous post Getting Html Fields Data into your TFS Warehouse I show how to add a new field. For this example we will add a new field that matches the images below.

imageimage

Note : There will be no reason to add this field to the layout.

Build

Next we will create a new Subscriber. Create a new Class Library and add a reference to

Microsoft.TeamFoundation.Framework.Server.dll, v11.0.0.0 – This assembly can be found in the project files attached but also in the directory C:\Program Files\Microsoft Team Foundation Server 11.0\Tools on the TFS server.

The function of interest for this post if the PopulateKanBanColumnField, this method is shown below but you can grab the project code and see the full implementation.
Update – Works with TFS 2012

private bool PopulateKanBanColumnField(WorkItem wiCurrent)
{
    bool result = false;

    if (wiCurrent.Fields.Contains("KanBan State") && wiCurrent.Fields["Work Item Type"].Value.ToString() == "User Story")
    {
        foreach (Field field in wiCurrent.Fields)
        {
            if (field.Name.ToLower().EndsWith(".kanban.column") && this.IsGUID(field.Name.Remove(field.Name.ToLower().IndexOf(".kanban.column"))) && wiCurrent.Fields["KanBan State"].Value != field.Value)
            {
                wiCurrent.Fields["KanBan State"].Value = field.Value;
                result = true;
            }
        }
    }

    return result;
}

Deploy

Now compile this and copy the output assemblies to C:Program FilesMicrosoft Team Foundation Server 11.0Application TierWeb ServicesbinPlugins on the TFS server.

Warning.

  1. Every time you move a work item that this subscriber effects it will save 2 revisions to the system, i.e.: when moving from Backlog to In progress it will save the work item and then the rule will fire find that work item in the store and then update the field.
  2. I have only tested that this works with TFS 2012 Update 2
  3. If a requirement is visible on 2 teams boards, then you need to read the extended column values for both teams and not stop after the first

Enjoy

Hope this helps and allows for more people to use the Kanban columns in there teams because they can now report on it Smile.

Download

BinargDigit.StoreKanBanInWarehouse.zip

Advertisements

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 )

Google+ photo

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

Connecting to %s