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.
In here, chose the required team project collection and expand the work item type (in our case Bug) from the specific team project.
Click on New as shown below.
A new window for Field Definition opens up and key in the values as shown below.
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.
Click on New as shown below.
There are various Rule Types already defined like below.
We need to choose the appropriate rule type based on our project needs. Here, I chose ALLOWEDVALUES, DEFAULT and REQUIRED.
ALLOWEDVALUES:
Click on New as shown below.
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.
DEFAULT:
Next, we will add another rule DEFAULT.
We will select From: as value and Value: as any 1 of the values from we created during ALLOWEDVALUES.
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.
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.
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.
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.
This will take us to the screen as shown below:
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.
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.
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.
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.
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.
This is really helpful, thanks!
ReplyDeleteGreat article and so helpful
ReplyDeleteThanks alot
How to customize state? Ex: i add new states: reopen, resolved,....
ReplyDeleteThks!
Nice Article! Though it is for VS 2010 but it did work for VS 2013 as well. Really helpful, Thanks!
ReplyDelete