1
votes

I have been looking into retrieving Work Items from Azure Devops with the azure-devops python package, and have managed to pull down work items with help from the sample code provided at:

https://github.com/microsoft/azure-devops-python-samples/blob/main/src/samples/work_item_tracking.py

However, I am trying to refine the process to grab a specific work item along with any linked 'related work' items. For instance, grabbing the parent, as well as "Test Feature"

How would I go about doing this?


Edit:

I've gotten closer to building this feature, however my query keeps returning every work item rather than just the linked items. My Goal is to retrieve all child items from the root work item of the tree.

wiql = Wiql(
   query="""
            SELECT * FROM workitemLinks 
            WHERE (Source.[System.AreaPath] Under 'devOpsTesting\\testArea')
            AND ([System.Links.LinkType] = 'System.LinkTypes.Hierarchy-Forward')
            AND (Source.[System.Id] = 3)  
            ORDER BY [System.Id]
            MODE (Recursive, ReturnMatchingChildren)
        """
)
1

1 Answers

1
votes

I found the solution to my problem, removing 'ReturnMatchingChildren' from MODE got rid of the extra returns. This solution assumes an item id of 3.

wiql = Wiql(
   query="""
            SELECT * FROM workitemLinks 
            WHERE (Source.[System.AreaPath] Under 'devOpsTesting\\testArea')
            AND ([System.Links.LinkType] = 'System.LinkTypes.Hierarchy-Forward')
            AND (Source.[System.Id] = 3)  
            ORDER BY [System.Id]
            MODE (Recursive)
        """
)