Edit

Share via


Query work items by link or attachment count

Azure DevOps Services | Azure DevOps Server | Azure DevOps Server 2022 | Azure DevOps Server 2020

Link work items to track related work and dependencies, and attach files to share information with your team. Query work items using the following fields:

  • Attached File Count
  • (Discussion) Comment Count
  • External Link Count
  • Hyperlink Count
  • Link Comment
  • Related Link Count
  • Remote Link Count
  • Attached File Count
  • (Discussion) Comment Count
  • External Link Count
  • Hyperlink Count
  • Link Comment
  • Related Link Count

For detailed field descriptions, see Fields associated with links and attachments.

Prerequisites

Category Requirements
Access levels - To view and run shared queries: Project member.
- To add and save a shared query: At least Basic access.
Permissions Contribute permission set to Allow for the folder that you want to add a query to. By default, the Contributors group doesn't have this permission.

Note

Users with Stakeholder access for a public project have full access to query features just like users with Basic access. For more information, see Stakeholder access quick reference.

Category Requirements
Access levels - To view and run shared queries: Project member.
- To add and save a shared query: At least Basic access.
Permissions Contribute permission set to Allow for the folder that you want to add a query to. By default, the Contributors group doesn't have this permission.

Supported operators and macros

Use the following operators for clauses that specify an integer field:

= , <> , > , < , >= , <=
=[Field], <>[Field], >[Field], <[Field], >=[Field], <=[Field]
In, Not In
Was Ever

List hierarchical items in a tree view

Create a query and select Tree of work items to begin. The Query Editor shows the following examples:

Note

You can't construct a query that shows a hierarchical view of Test Plans, Test Suites, and Test Cases because those items aren't linked together using parent-child link types. Use a direct links query to list test-related work items, or view the hierarchy on the Test Plans page.

Options for filters and query clauses

Change the filter options for linked work items and add query clauses by using the options in the Query Editor.

Filter for

Include these query clauses

Only child items of work item 645

Add to Filters for top-level work items:
ID = 645

Tasks or bugs

Add to Filters for linked work items:
Work Item Type In Task,Bug

Items assigned to my team (Web)

Add to both top and bottom filters:
Assigned to In Group [Fabrikam Fiber]\Web

Parent items of tasks assigned to me

Change Filter options to Match linked work items first
Add to Filters for linked work items:
Assigned To = @Me

List items based on linked dependents

The following example shows a dependent linked query that returns items with dependencies on work managed by other teams and projects.

The following query finds work items in all projects that are linked to work items under the Fabrikam area path and project using Predecessor and Successor link types.

Screenshot that shows a direct links query in the web portal.

  • Select Query across projects to include dependent linked work items from other projects.
  • Add the Area Path Under Fabrikam clause to filter for work items that are linked to items defined under the Fabrikam project.
  • Choose Only return items that have matching links, and then choose Return selected link types to return only work items linked as Predecessor or Successor.

List orphan user stories

If you organize user stories under features, find unparented stories quickly by doing one of the following actions:

  1. Open the product backlog and turn on the Parents On view option.
  2. Scroll to the Unparented Stories (Agile) or Unparented Backlog items (Scrum) section.

Screenshot that shows the product backlog with unparented stories.

Or, find unparented backlog items using a Work items and direct links query. For example, the following query lists active user stories for the Azure DevOps team that don't have a Parent link.

Screenshot that shows the Query Editor for unparented user stories in the web portal.

The following table describes fields associated with links and attachments. Most of these fields don't appear on the work item form but are tracked for all work item types.

Attached File Count

The number of files attached to the work item and stored in the work item tracking database.
Reference Name=System.AttachedFileCount, Data type=Integer

Note

For Azure Boards (cloud service), you can add up to 100 attachments to a work item. Attempts to add more results in an error message when you save the work item.

Comment Count

The number of comments added to the Discussion section of the work item.
Reference Name=System.CommentCount, Data type=Integer

External Link Count

The number of links from the work item to artifacts that aren't work items, such as pull requests, commits, changesets, or other link types.
Reference Name=System.ExternalLinkCount, Data type=Integer

Hyperlink Count

The number of hyperlinks that the work item contains.

Reference Name=System.HyperLinkCount, Data type=Integer

Link Comment

Contains comments from the team member who created the link. You can configure this field to appear as a column in a list of links on a work item form. (Not supported in the Query Editor.)

Reference Name=System.Links.Comment, Data type=PlainText

Link Description

Contains the work item type, ID, and title of the work item that is the target of the link. You can configure this field to appear as a column in a list of links on a work item form. (Not supported in the Query Editor.)

Reference Name=System.Links.Description, Data type=PlainText

Parent

When included as a column option in a backlog or query results list, the Title of the parent work item is displayed. Internally, the system stores the ID of the work item in an Integer field.

Note

You can add the Parent field as a column or specify it within a query clause by specifying the parent work item ID.
Reference Name=System.Parent, Data type=Integer

Parent

When included as a column option in a backlog or query results list, the Title of the parent work item is displayed. Internally, the system stores the ID of the work item in an Integer field.

Note

The Parent field is available from Azure DevOps Server 2020 and later versions. You can't specify this field within a query clause.
Reference Name=System.Parent, Data type=Integer

Related Link Count

The number of links defined for a work item that use a work link type, such as Parent-Child, Predecessor-Successor, and Related. For a full list, see Link type reference.
Reference Name=System.RelatedLinkCount, Data type=Integer

Remote Link Count

Available for Azure DevOps Services only. The number of links from a work item to work items defined in another organization. The same Microsoft Entra ID must manage the organizations. Supported link types include Consumes From, Produced For, and Remote Related. For more information, see Add link to work items, Link to a remote work item.
Reference Name=System.RemoteLinkCount, Data type=Integer

View related work items and objects within a work item by using the Work item visualization extension available from the Visual Studio Marketplace, Azure DevOps tab.

To add link types, see Manage link types [witadmin].

All tabs that support creating links between work items use the LinksControl element on the work item form. This element controls filtering and restricting the types of work items to which you can link. It also controls the types of links you can create and whether you can link work items in another project. To customize the link controls and restrictions, modify the definition of the LinksControlOptions for a work item type; see LinksControlOptions XML elements.

You can add or remove columns from the list of links, and you can customize the default columns and the column order. For more information, see LinksControlOptions XML elements.