开发者

TFS API - Why is the AllowedFieldValues for 'Reasons' empty?

I'm trying to retrieve the list of valid Reasons for a WorkItem (MS Agile 5 template), which works correctly for a new work item.

However for editing existing work items, the AllowedValues is always empty, whatever the state.

WorkItem item = GetItem(...)
item.Fields["Reason"].AllowedValues.ToList() // always empty

(ToList is my own extension method).

The problem is, the Visual Studio UI correctly updates the Reasons list when you change the state in the drop down list.

The Reason field also has IsLimi开发者_StackOverflow社区tedToAllowedValues=false but when you enter an arbitary value it complains that it's not a valid list item.


We also use MS Agile 5 & the following worked fine on an existing work items named myWorkItem (I tried with User Story & Task):

 FieldDefinitionCollection fdc = myWorkItem.Type.FieldDefinitions;
 Console.WriteLine(myWorkItem.Type.Name);
 foreach (FieldDefinition fd in fdc)
 {
    if(fd.Name == "Reason")
    {
      AllowedValuesCollection avc = fd.AllowedValues;
      foreach (string allowedValue in avc)
      {
        Console.WriteLine(allowedValue.ToString());
      }
    }                     
 }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜