1
votes

I came across this tutorial on how to programmatically pull Iteration Paths and Area Paths from TFS 2012 using their API.

http://geekswithblogs.net/TarunArora/archive/2011/07/10/tfs-2010-sdk-get-projects-iterations-area-path-queries-and.aspx

However, my company has set up some custom fields, one being "Team" (not to be confused with Team Projects that is already specified by TFS). In our Feature Request template, the user will click a dropdown menu and select the team they want to assign a project to. However, I haven't found a way to pull our team names programmatically like I can iteration paths and area paths.

Any ideas on how to pull custom fields?

1

1 Answers

0
votes

You need something like this:

var server = tfs.GetService<WorkItemStore>();

var projectName = "MyTeamProject";
var workItemTypeName = "Bug";
var fieldName = "Field.RefName";

var allowedValues =
    server
    .Projects
    .Cast<Project>()
    .Single(project => project.Name == projectName)
    .WorkItemTypes
    .Cast<WorkItemType>()
    .Single(workItemType => workItemType.Name == workItemTypeName)
    .FieldDefinitions
    .Cast<FieldDefinition>()
    .Single(field => field.ReferenceName == fieldName)
    .AllowedValues;