Search This Blog

Tuesday, September 14, 2010

How to add a Custom Field to an existing Work Item Type in TFS 2010 Process Template (MSF for Agile 5.0)

If there is a requirement to add a custom field to the TFS 2010 process template / to customize a Work Item Type in TFS 2010 by adding a custom field to it, then this post might be of use to you.

In my case, there was a specific requirement to add a custom field by name “Branch” to the Work Item “Bug” in order to track the bugs specific for each branch. We had a limited set of branches (MOSS 2007, SP 2010) so that we can track the same.

For this we need to have the TFS 2010 Power Tools installed which is available for download @ http://visualstudiogallery.msdn.microsoft.com/en-us/3e8c9b68-6e39-4577-b9b7-78489b5cb1da.

Once Power Tools is installed, we can customize the work item type by traversing thro the Tools menu of Visual Studio IDE.

Tools -> Process Editor -> Work Item Types -> Open WIT from Server.

1_open_wit 

In here, chose the required team project collection and expand the work item type (in our case Bug) from the specific team project.

2_wit

Click on New as shown below.

 3_new_wit

A new window for Field Definition opens up and key in the values as shown below.

4_field_defn 

Name: You can give in any name depending on your project requirements. In my case it is Branch.
Type: Chose from a list of available values (String, Integer, Double, Datetime etc). In this case I chose to have it as String.
Reference Name: This is the tricky part of it. Now we are going to define a custom type which is the Reference Name. There are some default types such as System.Id, System.AreaId, Microsoft.VSTS.Common.* etc which would not suit our needs for adding a custom field. Hence, we will have Reference Name as a custom defined type MyProject.Branch (thanks to Johnny Brown - my colleague for helping me to find this out).
Help Text: Help Text
Reportable: Chose from available values such as None, Dimension, Detail & Measure. For a more detailed explanation of what these values mean is explained @ http://msdn.microsoft.com/en-us/library/ms194942.aspx. Here I opted for Dimension.
Formula: This is enabled only when we chose Measure as Reportable.

And then let us move on to Rules tab.

5_rules

Click on New as shown below.

 6_rules_new

There are various Rule Types already defined like below.

 7_allowed_values

We need to choose the appropriate rule type based on our project needs. Here, I chose ALLOWEDVALUES, DEFAULT and REQUIRED.

ALLOWEDVALUES:

8_allowed_values

Click on New as shown below.

 9_allowed_values_new

which will take us to the List Item Edit window. From here we can add the values we had identified for the custom field. Here I added 3 values 2007, 2010 & Both.

10_list_item_edit

DEFAULT:

Next, we will add another rule DEFAULT.

11_default

We will select From: as value and Value: as any 1 of the values from we created during ALLOWEDVALUES.

12_default_value 

REQUIRED:

And then we will add the REQUIRED rule for which is fairly straight forward.

Finally, we will get a screen like the one shown below.

13_field_definition_ok

By clicking on OK here our new Custom Field is added to the Work Item Type -> Bug in our case. And the same should reflect as shown in the image below.

14_field_done 

Now as we have completed the creation of Custom Field, we need to move onto placing the newly created field in the layout of the Work Item. So let’s move onto Layouts tab as shown below.

15_layout 

We need to choose a location to place our newly created Custom Field. I preferred to have it along with Area & Iteration as these fields are most commonly used as filters in Reporting.

For this we need to Right Click on Column above a level to that of Area and chose New Control.

16_new_control

This will take us to the screen as shown below:

17_new_control

Onto the right, we need to modify the values of 2 fields (Label & Field Name). We will have the Label as Branch: and we can choose the Field Name from the list of available values. Here, we will have the newly created Custom Field during our previous step as one of the option.

18_field_name 

After giving the values Field Name and Label, let us have a feel of our new layout by clicking on the Preview Form as shown below.

19_preview_form

The layout should look something like below with the newly created Custom Field Branch having its values from the ALLOWEDVALUES rule we created earlier above.

20_preview_layout 

And as of now, we are not dealing with modifying the workflow. Hence I leave it here and click on Save. The Save should happen without any errors / exceptions. If it happens, we are successful in creating a Custom Field to an existing Work Item Type (wit).

To double check that we are successful in creating the Custom Field, try creating a new work item (bug) and which should land in a similar screen as shown below with the new Custom Field and its Values appearing as mentioned earlier.

21_bug_done 

The story doesn’t end here as we need to bring this newly created Custom Field into the Reports section which is much more twisting and I will explain the same in my next post here shortly.

4 comments:

  1. Great article and so helpful
    Thanks alot

    ReplyDelete
  2. How to customize state? Ex: i add new states: reopen, resolved,....

    Thks!

    ReplyDelete
  3. Nice Article! Though it is for VS 2010 but it did work for VS 2013 as well. Really helpful, Thanks!

    ReplyDelete