0

I am getting "InvalidListValue" error for all dropdown list fields in the WIT while saving the Work Item though TFS API.

I am trying to save the workitem using the below code :

            ArrayList result = workItem.Validate();
            if (result.Count <= 0)
            {
                productBackLogItem.Save();
            }

But, the result contains 8 "InvalidListValue" validation errors for all dropdown fileds in the WIT (my WIT has 8 dropdown list fields).

When I remove "AllowedValues" from the Temaplate, it is working fine.

I verified, both the "SuggestedValues" and "AllowedValues" has the same values. Please find the details below.

            <SUGGESTEDVALUES expanditems="true">
                <LISTITEM value="Added" />
                <LISTITEM value="Pending" />
            </SUGGESTEDVALUES>
            <ALLOWEDVALUES expanditems="true">
                <LISTITEM value="Added" />
                <LISTITEM value="Pending" />
            </ALLOWEDVALUES>

When I try to access the list of AllowedValues thought API, it is showing the count as 0.

           workItem.Fields["Sample.Control"].AllowedValues.Count

Thanks in Advance!

3 Answers3

0

TFS API just retrieve the Allowed values data from database, if the result value doesn't fullfill the requirement, you should modify the workitem definition.

As a workaround, you can add your account into "Project Collection Service Accounts" and then enable bypass rule which allow you to save and change work item values without obeying the work item rules. Refer to this question for more details: How to change workflow state of the newly created TFS work item through API?.

PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62
0

Thanks all. Finally it worked. Actually, I download the WIT and uploaded it without opening it in a editor and it worked.

Looks like, when I open it in a editor (I was using Sublime and Notepad++), it encodes the WIT in some format which TFS treats the Suggested and Allowed values differently.

0

I faced similar problem for one specific work item type (Requirement/CMMI). AllowedValues for other types and requirements from another project of the collection were available and everything worked fine.

Replacing of the template XML by the definitions from that another project didn't help. Digging into the validation results revealed that Microsoft.TeamFoundation.WorkItemTracking.Client.AllowedValuesCollection could not be loaded at all.

Cleaning up TFS cache has solved the problem.

grebus
  • 11
  • 2