Using TFS API to fetch All Priority Triage Severity values

654 Views Asked by At

I am building a Web Application using TFS API. I would like to fetch the All the range of "Priority" values from the TFS API and populate my asp.net dropdownlist. Similarly. I would like to fetch All the for `"Severity" and "Triage" and populate them into different dropdownlist.

I have an image of what I am talking about below :

enter image description here

Here is the code I have to access TFS Projects so far Can anyone let me know who I can access all the ITEMS TFS has for Priority, Severity & Triage :

Uri url = new Uri("server location");
NetworkCredential nc = new NetworkCredential(credentials, url);
TfsTeamProjectCollection coll = new TfsTeamProjectCollection(url, nc);
coll.EnsureAuthenticated();
WorkItemStore workItemStore = coll.GetService<WorkItemStore>();
1

There are 1 best solutions below

0
On BEST ANSWER

Something like

workItemStore.FieldDefinitions["Microsoft.VSTS.Common.Priority"].AllowedValues

or

var filters = new FieldFilterList();
filters.Add(new FieldFilter(CoreField.State, "New"));
workItemStore.FieldDefinitions["Microsoft.VSTS.Common.Priority"].FilteredAllowedValues(filters);

should work. Using the first or second example depends if you want all admitted values or just those admitted in a specific state; you can set even more complex filters.

Substitute Microsoft.VSTS.Common.Priority with the other fields you are interested in, the Reference names can be found here.