Question

Hi I am trying to add new workitems to the TFS repository using the API, but when I validate the workitem before it is saved, it returns an error. I previously got exceptions regarding the field definitions for a bug namely, Symptom, Steps to Reproduce and Triage. (Error code TF 26027). The code snippet is shown below: Can anyone tell me what's wrong here?

switch (workItemType)
        {
            case "Bug":
                {
                    workItem.Title = values["Title"].ToString();
                    workItem.State = values["State"].ToString();
                    workItem.Reason = values["Reason"].ToString();
                    workItem.Fields["Priority"].Value = values["Priority"].ToString();
                    workItem.Fields["Severity"].Value = values["Severity"].ToString();
                    //workItem.Fields["Triage"].Value = values["Triage"].ToString();
                    workItem.Fields["Assigned To"].Value = values["Assigned To"].ToString();
                    //workItem.Fields["Symptom"].Value = values["Symptom"].ToString();
                    //workItem.Fields["Steps to Reproduce"].Value = values["Steps to Reproduce"].ToString();

                    // Validate the Work Item fields.
                    ArrayList result = workItem.Validate();
                    // If any invalid fields are returned, report an error.
                    if (result.Count > 0)
                        MessageBox.Show("An Error occurred while adding the Bug to the repository.");
                    else
                        workItem.Save();
                }
                break;
Was it helpful?

Solution

To find the available field definitions, you can iterate over the collection (FieldDefinitions). The Name and ReferenceName properties are the values you can index by into the collection.

OTHER TIPS

the Field "Symptom" cannot be empty

Just reading the error message it looks like you are defining a field called "somefield" in your work item. I'm thinking that you have some old code hanging around elsewhere, maybe above the code snippet you posted, where you are defining a value for workItem.Fields["somefield"]

Old question, but hopefully helps someone. The field name is "Repro Steps"

.Fields["Repro Steps"].Value 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top