1

我正在尝试在中创建任务VSTS,但出现以下错误

TF401320:字段任务类型的规则错误。错误代码:必需、HasValues、LimitedToValues、AllowsOldValue、InvalidEmpty。

Exception明显,我缺少一个必填字段,即Task Type. 现在我无法找到Task Type. 谁能帮我这个。

下面是我正在编写的添加任务的代码:

string discipline = "Research Task";

if (taskDesc.Key.Contains("Configuration"))
{
    discipline = "Dev Task";
}
if (taskDesc.Key.Contains("Validation"))
{
    discipline = "Quality Task";
}

var workitemtype = "Task";
var document = new JsonPatchDocument();
document.Add(
    new JsonPatchOperation()
    {
        Path = "/fields/Microsoft.VSTS.Common.Discipline",
        Operation = Microsoft.VisualStudio.Services.WebApi.Patch.Operation.Add,
        Value = discipline
    });
document.Add(
    new JsonPatchOperation()
    {
        Path = "/fields/System.Title",
        Operation = Microsoft.VisualStudio.Services.WebApi.Patch.Operation.Add,
        Value = string.Format("{0} {1}", porIDText, taskDesc.Key)
    });
document.Add(new JsonPatchOperation()
{
    Path = "/fields/System.AreaPath",
    Operation = Microsoft.VisualStudio.Services.WebApi.Patch.Operation.Add,
    Value = System.Configuration.ConfigurationManager.AppSettings["AreaPath"]
});
document.Add(
    new JsonPatchOperation()
    {
        Path = "/fields/System.AssignedTo",
        Operation = Microsoft.VisualStudio.Services.WebApi.Patch.Operation.Add,
        Value = "<name>"
    });
document.Add(
    new JsonPatchOperation()
    {
        Path = "/fields/System.Description",
        Operation = Microsoft.VisualStudio.Services.WebApi.Patch.Operation.Add,
        Value = taskDesc.Value
    });
var wi = client.CreateWorkItemAsync(
document,
teamProjectName,
workitemtype).Result;
4

1 回答 1

1

您可以将任务类型字段添加到任务工作项,但不要添加到布局中。

在此处输入图像描述

您可以在 Web Access 中检查任务工作项的字段(转到集合页面 > 设置 > 流程 > 选择模板 > 工作项类型 > 任务 > 字段)或通过REST API

任务类型字段的设置值:

代码:

    document.Add(
        new Microsoft.VisualStudio.Services.WebApi.Patch.Json.JsonPatchOperation()
        {
            Path = "/fields/Microsoft.VSTS.CMMI.TaskType",
            Operation = Microsoft.VisualStudio.Services.WebApi.Patch.Operation.Add,
            Value = "Type1"
        });
于 2017-02-02T04:38:01.470 回答