azure-devops-rest-apiazure-devops-extensions

Using azure-devops-extension-api or azure-devops-rest how can I get the Areapaths linked to a Team


I am trying to create an extension the main functionality of my custom hub is to create a User Story Mapping experience. My goal is to allow the user to search for an Epic from any project they have access to and present it in this specific layout.

In this layout, the positioning—more to the left and lower down—carries significant importance. This is where the need for reordering arises. I want to use the reorderBacklogWorkItems method from WorkRestClient using azure-devops-extension-api to achieve this. My goal is to effectively reorder work items to change the value of Microsoft.VSTS.Common.StackRank. For example:

Suppose I have the following items from the same Team:

1001 Epic

1002 Feature

1003 HU 1

1004 HU 2

1005 HU 3

1006 HU 4

I want HU 4 (1006) to appear at the beginning of the list, resulting in the following order:

1001 Epic

1002 Feature

1006 HU 4

1003 HU 1

1004 HU 2

1005 HU 3

The problem I'm facing is that the reorderBacklogWorkItems method requires a team, as stated in the documentation: Microsoft Docs. However, I do not have the team information available but do have the Area path.

Here is a more complete example of what I am doing: First, The user perform a query and the user can search cards from different projects or teams then I get the data "WorkItem[]" like this:

const allIds = [1001, 1002, 1003, 1004, 1005, 1006]// this is an example because I really get the Ids from the query.
const client = getClient(WorkItemTrackingRestClient);
const workItems = client.getWorkItems(allIds, undefined, undefined, undefined, 4, undefined);

I display these work items to the user, who then identifies the need for a change in the order(the reorder function is not the main purpose of the extensión but this is one of the features that we want to implement). At this point, I only have workItems, which is of type WorkItem[]. This data only includes the area path, but not the team information.

My question is which Method or Api give me the Area paths that are linked to a team? I could use azure-devops-extension-api or azure-devops-rest

The getTeamSettings method and getTeams do not provide information about which area path a team has.


Solution

  • Which method or API can give me the area paths that are linked to a team? I could use azure-devops-extension-api or azure-devops-rest

    To get the area paths that linked to a team, you can use the following method in azure-devops-extension-api or azure-devops-rest-api.

    Azure DevOps Rest API: Teamfieldvalues - Get

    GET https://dev.azure.com/{organization}/{project}/{team}/_apis/work/teamsettings/teamfieldvalues?api-version=5.1
    

    Azure-devops-extension-api: WorkRestClient class -> getTeamFieldValues(TeamContext)

    function getTeamFieldValues(teamContext: TeamContext): Promise<TeamFieldValues>
    

    In the response, you can check the values field in the response. It contains all area paths linked to the team.