0

We are using TFS 2012 with a SCRUM Template. We have 9 custom columns in our Product backlog board in TFS 2012. How do I get the Column name for each Product Backlog Item using the TFS API libraries?

eg.

WorkItemCollection wic = workItemStore.Query(wiql);
foreach (WorkItem wi in wic)
{
    //This is not the right property, only values such as New, Committed, Done.
    var notColumnName = field.State; 
}

The Columns

Our column names do not align to the State value when I view "Customize Columns" therefore I can't use the value of WorkItem.State. I'm unsure if this is correct or not, it was setup by our architect to work this way and that's what we have.

Jafin
  • 4,153
  • 1
  • 40
  • 52

1 Answers1

0

Not sure if the values you listed are field names or possible states of the PBI. To get the value of any field, you can use this:

var fieldValue = wi.Fields["System.State"].Value;
fieldValue = wi.State;

If these are field names you can use the name instead the reference name for it:

Field assigned = wi.Fields.["Assigned To"]; //works
Field storyChange = wi.Fields.["Story Change"];

You can check the WorkItemTypeDefinition if you are not sure about the names or reference names.

MikeR
  • 3,045
  • 25
  • 32
  • The "column name" doesn't appear to be in the collection of field properties when I enumerate the entire collection. – Jafin Feb 10 '14 at 23:31
  • I compared it to our environment and these values are not fields of the PBI, they are states of PBI. So in wi.State you should find the values or check the Work Item Type Definition (Visual Studio -> Tools -> Process Editor -> Work Item Types -> Open from Server -> Select the PBI from your TeamProject -> Workflow) if these states are still valid or not. – MikeR Feb 11 '14 at 07:43