Wednesday, December 9, 2009

Get List of Allowed Values in TFS Work Item Field

This is how you can obtain programmatically a list of allowed values in a TFS Work Item field (in the example below, in Priority field in Bug template):

TeamFoundationServer tfs = new TeamFoundationServer("myTFServer");

WorkItemStore wis = (WorkItemStore)tfs.GetService(typeof(WorkItemStore));

Project teamProject = wis.Projects["myTeamProjectName"];

WorkItemType wit = teamProject.WorkItemTypes["Bug"];

 

FieldDefinition fd = wit.FieldDefinitions["Microsoft.VSTS.Common.Priority"];

AllowedValuesCollection avc = fd.AllowedValues;

 

foreach (var row in avc)

{

Console.WriteLine(row);

}

2 comments:

  1. hi,

    First of all. Thanks very much for your useful post.

    I just came across your blog and wanted to drop you a note telling you how impressed I

    was with the information you have posted here.

    Please let me introduce you some info related to this post and I hope that it is useful

    for .Net community.

    There is a good C# resource site, Have alook

    http://www.csharptalk.com

    simi

    ReplyDelete
  2. thanks...exactly what i was looking for. oh and poster Simi bot above your a spammer A$$.

    ReplyDelete