microsoft / azure-devops-extension-api

REST client libraries and contracts for Azure DevOps web extension developers.
MIT License
100 stars 49 forks source link

Problem creating nested classification nodes #38

Open daniel-ohrn opened 4 years ago

daniel-ohrn commented 4 years ago

Hey,

Let's hope this question ends up in the right place:

We have been struggling with this issue for quite a while now, what we are trying to achieve is to create nested classification nodes via the azure-devops-extension-api package according to the following structure:

-Root --Release ---Sprint 1 ---Sprint 2

This works as expected when using the REST-api directly but when we use the npm package the classification nodes gets created in a flat structure directly under the root node.

We have tried many different versions of the code below but since none of them works my question is as follows:

How do I create a child node under a parent?


// parent object 
  const parent = {
    name: "Parent",
    attributes: {
      startDate: new Date(),
      finishDate: addDays(new Date(), 10)
    },
    id: undefined,
    children: undefined,
    hasChildren: true,
    identifier: undefined,
    path: "",
    url: undefined,
    _links: undefined,
    structureType: TreeNodeStructureType.Iteration
  };

// create the parent object 
  const parentNode = await getClient(
    WorkItemTrackingRestClient
  ).createOrUpdateClassificationNode(
    parent
    projectId,
    TreeStructureGroup.Iterations
  );

// child object 
  const child = {
    name: "Child",
    attributes: {
      startDate: new Date(),
      finishDate: addDays(new Date(), 10)
    },
    id: undefined,
    children: undefined,
    hasChildren: true,
    identifier: undefined,
    path: "Parent",
    url: undefined,
    _links: undefined,
    structureType: TreeNodeStructureType.Iteration
  };

// create the child node 
  const childNode = await getClient(
    WorkItemTrackingRestClient
  ).createOrUpdateClassificationNode(
    child,
    projectId,
    TreeStructureGroup.Iterations
  );
chris77c commented 5 months ago

I meet the same issues; are you solve it? @daniel-ohrn

chris77c commented 5 months ago
       // finishDate should greater startDate            
       //@ts-ignore
        const postedNode: WorkItemClassificationNode = {
            name: newNodeName,
            attributes: {
                startDate: startDate_1,
                finishDate: endDate_2,
            },
            structureType: TreeNodeStructureType.Iteration
        }; 

this is working for me