Edit

Share via


View, run, or email a work item query

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

Visual Studio 2022

This article describes how to access and interact with Azure Boards work items by running and sharing queries. You can view and run built-in or shared queries to identify work items assigned to you or that meet other criteria.

Prerequisites

  • An Azure DevOps project that has work items assigned to or followed by you, or queries defined by or shared with you. To define a query, see Define a work item query.
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.

Open the Queries page

To open the Queries page for your project, select Boards > Queries. The Queries page opens to the Favorites tab, showing queries you or your team chose as favorites. For more information, see Set personal or team favorites.

The Favorites tab also shows the last queries you opened under Continue where you left off.

Screenshot of the Favorites tab on the Queries page.

To see all personal and shared queries in your project, select the All tab on the Queries page. The All tab shows built-in queries, queries that you defined, and queries that are shared in your project. Expand the My Queries, Shared Queries, and other folders to access their queries.

Screenshot of the Queries page All tab.

Screenshot of the All tab on the Queries page.

On the All tab of the Queries page, the My Queries folder contains the following built-in queries in addition to the ones you define:

  • Assigned to me uses the @Me macro to list all work items assigned to you in the current project.
  • Followed work items uses the @Follows macro, ID in @Follows, to list all work items you're following. For more information, see Follow a work item or pull request.

All and Favorites tab supported tasks

You can do most tasks for viewing and running queries from either the All or Favorites tab of the Queries page, as indicated in the following table.


Task
Favorites All
List all favorited queries, yours or a team you belong to ✔️
List all your queries or shared queries for the current project ✔️
Favorite a query ✔️
Unfavorite a query ✔️ ✔️
Filter the list of queries ✔️ ✔️
Expand or collapse folders ✔️ ✔️
Run a query or open the context menu for a query ✔️ ✔️

Only the built-in queries and queries you save under My Queries appear under My Queries. Only queries you favorite appear in My Favorites. Only queries saved under Shared Queries can be favorited by a team.

Filter the list of queries

Enter a keyword into the filter box on either the Favorites or All tabs of the Queries page to filter the queries displayed. For more information, see Interactively filter backlogs, boards, queries, and plans.

Screenshot showing all queries in the project filtered by a keyword criteria.

Screenshot showing all queries in the project filtered by a keyword criteria.

From either the Favorites or All tab of the Queries page, you can navigate to find and open specific queries.

On the All tab, query pages can appear directly or be in folders or subfolders. You can navigate to a folder, subfolder, or query page.

As you make selections and open folders, breadcrumbs are shown at the top of the page.

Screenshot of breadcrumbs on query page.

Screenshot of breadcrumbs on query page.

You can select a folder within the breadcrumb to open the folder.

Screenshot of queries breadcrumb example.

You can also open a favorite query or return to the All queries page from the dropdown menu of an open query.

Screenshot of query dropdown.

Screenshot of query navigation dropdown.

Run a query

To run a query from either the Favorites or All tabs of the Queries page, expand its folder if necessary and select the query. The query Results page opens.

You can also select the More actions icon next to the query on the Queries page and select Run query or other options from the context menu.

Screenshot of the context menu for a query on the Queries page.

Run a query from the Azure DevOps CLI

You can run an Azure Boards query by using the az boards query command in the Azure DevOps command line interface. To get started, see Get started with Azure DevOps CLI.

az boards query [--id] [--org] [--path] [--project] [--wiql] 

Parameters

  • id: The ID of an existing query. Required unless --path or --wiql is specified.
  • wiql: The query in Work Item Query Language (WIQL) format. Ignored if --id or --path is specified.
  • path: The path of an existing query. Ignored if --id is specified.
  • org: Azure DevOps organization URL, such as --org https://dev.azure.com/MyOrganizationName/. Required unless configured as default or picked up using git config. Configure the default organization using az devops configure -d organization=ORG_URL.
  • project: Project name or ID. Required if not configured as default or picked up using git config. Configure the default project using az devops configure -d project=NAME_OR_ID.

Examples

The following command runs a query with the specified ID and shows the result in table format.

az boards query --id 6c286d74-26a5-4cce-bfcf-bf9123495bfe  --output table

Priority    Node Name         Work Item Type    Title                             Remaining Work
----------  ----------------  ----------------  --------------------------------  ----------------
1           Voice             Bug               Apply fix elsewhere as needed
2           CMMI              Bug               Slow response on form

The following command runs a WIQL query and shows the result in table format.

az boards query --wiql "SELECT [Microsoft.VSTS.Common.Priority], [System.NodeName], [System.WorkItemType], [System.Title], [Microsoft.VSTS.Scheduling.RemainingWork] FROM workitems WHERE [System.WorkItemType] = 'Bug' AND [System.AreaPath] = 'Fabrikam Fiber' ORDER BY [System.WorkItemType]" --output table

Priority    Node Name       Work Item Type    Title                  Remaining Work
----------  --------------  ----------------  ----------------       ----------------
2           Fabrikam Fiber  Bug               Slow response on form
2           Fabrikam Fiber  Bug               Check permissions

Email or share a query

From the query Editor or Results view, you can email a formatted list of query items to project members or copy the query URL to share.

Select the More actions icon at upper right and then select Email query or Copy query URL from the context menu.

Screenshot of Choose Email query or Copy query URL.

Screenshot of Choose Email query or Copy query URL.

You can send email only to individual project members that the system recognizes. Sending to a team group or security group isn't supported. Recipients must have permissions to read the mailed work items.

The email sends through your default mail client, and includes a link to the query that returns only the listed work items. For more information, see Copy or clone work items.

Note

To email a formatted list to people who aren't project members, see Copy or email a list of work items.

Note

For on-premises Azure DevOps, all email actions require an Simple Mail Transfer Protocol (SMTP) server to be configured. If you don't have an SMTP server configured, you can work around this requirement by using Copy as HTML as described in Copy or email a list of work items.

View work items in Visual Studio

On the Work Items page of the Visual Studio Team Explorer, you can list work items for connected projects. Query creation and management must be done in the Azure Boards web interface.

In the Work Items Search pane, you can apply filters to view listed work items by Assigned to, Created by, State, or Work Item Type.

You can expand the Work Items list and select the dropdown arrow next to the current view to select built-in Assigned to Me, Following, Mentioned, or My Activity views.

Screenshot of Work Items page showing view options.

For listed individual work items, you can:

  • Hover over the work item to display information.
  • Select a work item title to rename the work item.
  • Right-click the work item to assign it to yourself or to complete the work item.
  • Double-click the item or right-click and select Open to open the work item in the Azure Boards UI.

Screenshot of options for work items on the Team Explorer Work Items page.

You can also create work items by selecting New Work Item and entering a work item title. Changes you make through Visual Studio are reflected in Azure Boards.

Next step