Get required fields for some WorkItem

2019-08-27 10:48发布

Is it possible to get such XML, using TFS API or other tools? This XML contains information about the fields that must be filled in translation work item to another status.

Screen here http://sqlrefactorstudio.com/content/png/TFS%20Work%20item%20required%20fields.png

标签: tfs tfs2012
1条回答
欢心
2楼-- · 2019-08-27 11:09

Using the TFS API in the simple example below will write out the required fields for a given work item.

    /// <summary>
    /// Writes out the required fields for a work item.
    /// </summary>
    /// <param name="workItemId">The ID of a work item.</param>
    private static void _GetRequiredFieldsForWorkItem(int workItemId)
    {
        using (TeamProjectPicker tpp = new TeamProjectPicker(TeamProjectPickerMode.SingleProject, false, new UICredentialsProvider()))
        {
            if (tpp.ShowDialog() == DialogResult.OK)
            {
                TfsTeamProjectCollection projectCollection = tpp.SelectedTeamProjectCollection;
                WorkItemStore store = projectCollection.GetService<WorkItemStore>();

                Console.WriteLine("Required Work Item Fields");
                Console.WriteLine("-------------------------------");

                WorkItem item = store.GetWorkItem(workItemId);
                foreach (Field field in item.Fields)
                {
                    if (field.IsRequired)
                    {
                        Console.WriteLine(field.ReferenceName);
                    }
                }
            }
        }
    }
查看更多
登录 后发表回答