admin管理员组

文章数量:1124679

I'm working with an Azure DevOps WIQL Query. We are trying to do a query on "WorkItems", that returns a lot of records, but will also need to know the parent of every record. My hope was that I would be able to make a query to "WorkItemLinks" instead, but we are receiving different results.

Here is my WIQL syntax that returns the items we are looking for:

SELECT [System.Id] FROM WorkItems WHERE [State] = "To Do" AND [System.TeamProject] = @project

In order to get the ID of every WorkItem, I would then need to make GET requests to get all the WorkItems individually. My hope was that I might be able to make use syntax like

SELECT [System.Id] FROM WorkItemLinks WHERE [Target].[State] = "To Do" AND [Target].[System.TeamProject] = @project

At first glance, this looks to me like it should return the link information for all of the same WorkItems as the first query, but in practice it returns entirely different results. While some of the same WorkItems are included, there are many that are not, and many are included that are not found by the first query.

Can someone explain why these two queries return completely different results?

I'm working with an Azure DevOps WIQL Query. We are trying to do a query on "WorkItems", that returns a lot of records, but will also need to know the parent of every record. My hope was that I would be able to make a query to "WorkItemLinks" instead, but we are receiving different results.

Here is my WIQL syntax that returns the items we are looking for:

SELECT [System.Id] FROM WorkItems WHERE [State] = "To Do" AND [System.TeamProject] = @project

In order to get the ID of every WorkItem, I would then need to make GET requests to get all the WorkItems individually. My hope was that I might be able to make use syntax like

SELECT [System.Id] FROM WorkItemLinks WHERE [Target].[State] = "To Do" AND [Target].[System.TeamProject] = @project

At first glance, this looks to me like it should return the link information for all of the same WorkItems as the first query, but in practice it returns entirely different results. While some of the same WorkItems are included, there are many that are not, and many are included that are not found by the first query.

Can someone explain why these two queries return completely different results?

Share Improve this question asked yesterday David Carli-ArnoldDavid Carli-Arnold 334 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

It looks like you are trying to query linked work items:

SELECT [System.Id] FROM WorkItemLinks WHERE [Target].[State] = "To Do" AND [Target].[System.TeamProject] = @project

Try to query source items:

SELECT [System.Id] FROM WorkItemLinks WHERE [Source].[State] = "To Do" AND [Source].[System.TeamProject] = @project

Additionally, you may query through the link type:

SELECT [System.Id] FROM WorkItemLinks WHERE [Source].[State] = "To Do" AND [Source].[System.TeamProject] = @project and [System.Links.LinkType] = 'System.LinkTypes.Hierarchy-Reverse' MODE (MayContain)

Useful links:

  • Query for links between work items
  • Reference guide for link types

本文标签: