您好我正在尝试使用API将新工作项添加到TFS存储库,但是当我在保存工作项之前验证工作项时,它会返回错误。我以前有一个关于bug的字段定义的例外,即症状,重现步骤和分类。 (错误代码TF 26027)。代码片段如下所示:任何人都可以告诉我这里有什么问题吗?
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;
答案 0 :(得分:2)
要查找可用的字段定义,您可以迭代集合(FieldDefinitions)。 Name和ReferenceName属性是您可以将其索引到集合中的值。
答案 1 :(得分:1)
字段“症状”不能为空
答案 2 :(得分:0)
只是阅读错误消息,您似乎在工作项中定义了一个名为“somefield”的字段。我想你在其他地方有一些旧的代码,可能在你发布的代码片段之上,你在哪里为workItem.Fields定义一个值[“somefield”]
答案 3 :(得分:0)
老问题,但希望可以帮助某人。字段名称为“Repro Steps”
.Fields["Repro Steps"].Value