Search This Blog

Thursday, December 06, 2007

TF20015: The field 'xxx' contains a value that is not in the list of supported values.

While trying to save a work item in TFS you might be facing a problem doing it when the error TF20015 is raised. This error is raised when you are trying to enter values that are not part of the allowed values of the field. The strange thing is that it can happen although the value was already saved before to the work item and the field is disabled. As a result you cannot change the value and therefor cannot save the work item. So why does it happen? I faced this problem in two cases:


  1. The user in one of the fields (which is implementing the valid user value list as the allowed values for the field) was renamed or deleted.

  2. The work item schema was changed in a way that made some of the existing work items have illegal values. For example, if you made one of the fields mandatory trough all of the work flow and you have some work items with a null value in the field.

So, how can you fix it?


There are 2 ways to do it:



  1. Changing the work item schema temporarily so the field won't be disabled and then you can change the value.

  2. Write some code the change the field value:

Here's a code sample on how to update work item field values:


public void UpdateWorkItem(string serverUri, int id, string fieldName, string fieldValue)
{
TeamFoundationServer tfs = new TeamFoundationServer(serverUri);
tfs.EnsureAuthenticated();
WorkItemStore wis = tfs.GetService(typeof(WorkItemStore)) as WorkItemStore;
WorkItem workItem = wis.GetWorkItem(id);
workItem.Open();
workItem.Fields[fieldName].Value = fieldValue;
workItem.Save();
}


2 comments:

Rob said...

So how do we change the work item schema??

Dudu Shmaya said...

You can use the ALLOWEXISTINGVALUE (http://msdn.microsoft.com/en-us/library/aa337642(VS.80).aspx) element.