Ferdi Öztürk Ferdi Öztürk - 1 year ago 77
reST (reStructuredText) Question

Usage: UpdateWorkItemTypeDfeinition() how to?

I created an VSTS extension in typescript to upload XML code to TFS (WIT code).

UpdateWorkItemTypeDefinition seemed the correct way to do it. But I cannot get it to work. The first param is taking WorkItemTypeTemplateUpdateModel, means .actionType, .template, .templateType and .methodology

Can please someone explain the usage of these members or give sample snippet please (there is not much documentation on visualstudio.com and I could not find any examples)

Methodology is unclear to me. Is this "agile" vs. "scrum"? Why is this needed at all, if I just want to update the existing WIT?

Answer Source

I cannot find any information about "Methodology" either, but it seems that this information is not required for now since I can update the work item type definition without this information.

For other options:

ActionType is the action which you'd like to execute with UpdateWorkItemTypeDfeinition() method. There are two options: Import and Validate. "Import" will update/create the work item type definition while "Validate" only validates if the template is correct. When the action type is "Import", you must specify the project name when run UpdateWorkItemTypeDfeinition() method.

TemplateType is the type of the definition you'd like to update. There are also two options: WorkItemType and GlobalWorkflow.

Template is a string that contains all the definition for the work item type.

Here is a sample code with C#, the usage from Typescript is similar with it since they both use RestAPI:

using System;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.WorkItemTracking.WebApi;
using Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models;

namespace Conso
    class Program
        static void Main(string[] args)
            string tfsurl = "http://xxx:8080/tfs/DefaultCollection/";
            string projname = "ProjectName";
            TfsTeamProjectCollection ttpc = new TfsTeamProjectCollection(new Uri(tfsurl));
            string template = System.IO.File.ReadAllText(@"D:\Code\bug.xml");
            WorkItemTrackingHttpClient witc = ttpc.GetClient<WorkItemTrackingHttpClient>();
            WorkItemTypeTemplateUpdateModel updatemodel = new WorkItemTypeTemplateUpdateModel();
            updatemodel.ActionType = ProvisioningActionType.Import;
            updatemodel.TemplateType = TemplateType.WorkItemType;
            updatemodel.Template = template;
            ProvisioningResult pr = witc.UpdateWorkItemTypeDefinitionAsync(updatemodel,projname).Result;