Forum Discussion

ccclever2's avatar
ccclever2
Copper Contributor
Mar 18, 2025

Get Root Path Area ID [Azure Devops Extension]

Hi,

I am developing an extension for Azure Devops. The extensions aims to render content on the work item page depending on the work item's area path ID. I managed to retrieve the available area path IDs using the Extension API:

import { getClient } from "azure-devops-extension-api";
const witClient = getClient(WorkItemTrackingRestClient);
const rootPath = await witClient.getClassificationNode(project!.name, TreeStructureGroup.Areas, '', 20)

This returns all available Area Paths (until depth 20) for the current project.

Example:

ID=4, NAME='\proj_name\Area'
ID=5, NAME='\proj_name\Area\custom-area'
ID=6, NAME='\proj_name\Area\custom-area\sub1'

However I recognized that the very root Area Path (lowest ID) does not correspond to the actual Root Area Path ID of the project. When I create a work item and assign it to the default root Area, and retrieve the work item's Area Path ID by

const areaPathID = workItemFormService.getFieldValue("System.AreaID")

the actual returned ID is 2. It seems to be always the lowest readable ID subtracted by 2 across different projects. When listing the Area Path IDs as a column in a query, ID=2 is also shown instead of ID=4. Is there a way to read the actual root Area Path ID and why does the reading it differ from the actual ID?

 

1 Reply

  • How about considering Cross-Reference Using Classification Data:

    • Retrieve the complete area tree using the Extension API with getClassificationNode.
    • Identify the root node by matching the name (which should be the same as the project name) or by its position at the top of the hierarchy.
    • Use the raw node ID from this call if you need the underlying classification node identifier.

Resources