0

Currently I can get all of the TFS contributors using workItemStore.FieldDefinitions[CoreField.AssignedTo].AllowedValues, but the thing is that I want to search for the allowed members of a specific project(I already have the project info extracted from TFS), as the results are in the hundreds instead of just 5-6.

Any suggestions are welcome.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Phantomazi
  • 408
  • 6
  • 22
  • Not wat you are asking, but usually if people ask this they actually want to list members of the team within a project or a single security group of a project; http://blog.johnsworkshop.net/tfs11-api-query-teams-and-team-members/ – Rolf Huisman Aug 06 '15 at 21:10

1 Answers1

0

You can use the following code to get valid user for a specific team project:

List<string> displayNames = new List<string>();
        TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new Uri("http://tfsservername:8080/tfs/collectionname"));
        tfs.EnsureAuthenticated();
        WorkItemStore workItemStore = (WorkItemStore)tfs.GetService(typeof(WorkItemStore));

        WorkItemTypeCollection workItemTypes = workItemStore.Projects["Agile"].WorkItemTypes;

        WorkItemType wiType = workItemTypes["task"];

        var allowedValues = wiType.FieldDefinitions[CoreField.AssignedTo].AllowedValues;

        foreach (String value in allowedValues)
        {
            displayNames.Add(value);
        }

However, for your data-binding requirement, could you please offer more information? By the way, what kind of project you're working with? A winform project?

Vicky - MSFT
  • 4,970
  • 1
  • 14
  • 22
  • I have edited my question, so as your answer turned extremely useful, please edit it so it suits fully the question and I will accept it :) Thank you ! – Phantomazi Aug 07 '15 at 14:39