Export (0) Print
Expand All

Query for work items

Queries help you find work items that you want to review or update.

Use the search box to find work items. Enter the ID or use filters. If you want a flat list of work items, a hierarchical list using a tree query, or a list showing dependencies using a direct links query, use the query editor to choose the query type.

You can create queries in Visual Studio Online, Team Web Access (TWA), and Team Explorer. Also, you can open a query in Excel or Project to perform bulk modifications.

Type the ID in the Search work items box and then choose the search icon.

Seach work items text box

Using the Context Menu Icon context menu, you can add filters to list items based on assignment, status, a keyword, or a work item type.

For example, enter A=@Me T=Task to list all tasks assigned to you.

The easiest way to define a query is to start with an existing shared query. The following example shows how to find all closed bugs by modifying the Active Bugs shared query provided with the Agile process template.

  1. Open a shared query. For example, open the Active Bugs or similar flat list query.

    Open shared query, e.g., Active Bugs

       

  2. Edit the query to find closed bugs and then run the query. Use Add Attachment (Insert new filter line) to insert a clause above the current clause. Use Delete clause (Remove filter line) to delete a clause.

    Editor view of a flat list query

       

  3. Save the query to your My Queries folder.

    Save Query As, Folder=My Queries

       

    To save a query to the Shared Queries folder, you need to be a team administrator, a member of the Project Administrators group, or have your Contribute permissions on the folder set to Allow.

Start from the New menu on the queries page in TWA, or work items page in Team Explorer.

Open a new query

Grouped clauses operate as a single unit separate from the rest of the query, similar to putting parentheses around a mathematical equation or logic expression. The And or Or operator for the first clause in the group applies to the whole group.

In the next example, the first expression returns all work items that are priority 1 and all active bugs of any priority. The second expression returns all active priority 1 work items and all priority 1 bugs, whether they are active or not.

Grouped clauses

Logical expression

Filter using an or/and logical expression

Priority=1 OR (Work Item Type=Bug AND State=Active)

Filter using an and/or logical expression

Priority=1 AND (Work Item Type=Bug OR State=Active)

To group one or more clauses, select them and then choose the Group Query Clause group clauses icon.

Group selected query clauses

If your query results do not return your expected set of work items, follow these steps:

  • Make sure that each clause is defined as you intended.

  • Verify And/Or assignments to each clause. If your results contain more work items than expected, often an Or clause is present instead of an And clause.

  • Determine if you need to group or change the grouping of the query clauses and the And/Or assignments of each grouped clause.

  • Add more query clauses to refine your query filter criteria.

  • Review the options available to specify fields, operators, and values.

Use the tree query (Tree Query) to view a multi-tiered, nested list of work items. For example, you can view all backlog items and their linked tasks.

Results list showing a tree query

Expand (Expand node (Team Web Access)) or collapse (Collapse node (Team Web Access)) leaf nodes to focus on different parts of the tree.

Define the filter criteria for both parent and child work items.

Tree query filters

To find linked children, select Match top-level work items first. To find linked parents, select Match linked work items first.

Use the direct links query (Direct Links Query) to track work items that depend on other tracked work, such as tasks, bugs, issues, or features. For example, you can view backlog items that depend on other items being implemented or a bug being fixed.

Direct links query results

Use the direct links query to track dependencies your team has that other teams work on, or manage commitments your team has made to other teams. Specify the filter criteria for both top and linked work items, and select the types of links used to filter the dependencies.

Direct links query editor

Filter your first-tier list of work items by choosing one of these options:

  • Only return work items that have the specified links: First-tier work items are returned, but only if they have links to work items specified by the linked work items filter criteria.

  • Return all top level work items: All first-tier work items are returned regardless of the linked work items filter criteria. Second-tier work items that are linked to the first tier are returned if they match the linked work items filter criteria.

  • Only return work items that do not have the specified links: First-tier work items are returned, but only if they do not have links to work items specified by the linked work items filter criteria.

A: The operators and variables available for selection depend on the field that you select. The four variables are @Project for the project name field, @Me for person-name fields, @Today for date-time fields, and [Any]. See Query fields, operators, values, and variables.

A: From Visual Studio Online and TWA, you can chart the results of any flat-list query. You must be a member of the full access group in TWA.

Or, you can open a query in Excel and use the features of Excel to generate a chart.

A: There’s no automatic way to do this; you must manually update queries to point to the current sprint. If your team project is based on Scrum or Agile, you’ll find a set of queries under the Current Sprint or Current Iteration folders. For each query to return items defined for the current sprint, you must update the iteration path to the iteration that is current according to the date.

You can change many of your queries by saving them as .wiq files. Open the query in Team Explorer, choose Edit Query, and then choose File, Save As to save each query as a .wiq file. Here is an example of the Work in Progress query that has been updated to support Release 2\Sprint 59.

<?xml version="1.0" encoding="utf-8"?>
<WorkItemQuery Version="1">
  <Wiql>
    SELECT [System.Id],
           [System.WorkItemType],
           [System.Title],
           [System.AssignedTo],
           [System.State],
           [Microsoft.VSTS.Scheduling.RemainingWork],
    FROM WorkItems 
      WHERE [System.TeamProject] = @project and 
            [System.IterationPath] under 'FabrikamPrime\Release 2\Sprint 59' and 
            [System.WorkItemType] in group 'Microsoft.TaskCategory' and 
            [System.State] = 'In Progress' 
      ORDER BY [System.AssignedTo],
               [Microsoft.VSTS.Common.BacklogPriority],
               [System.Id] 
   </Wiql>
</WorkItemQuery>

A: Open Column Options to add or remove columns, change the sequence of columns, and change the sort order within a column.

Display columns tab in Column Options dialog box

Also, from the results list, you can drag a column to a new position and select the column title to change the sort order by column.

A: Yes if you’re using Visual Studio Online or if you’ve upgraded to TFS 2013 Update 2, otherwise, no for on-premises deployments.

For Visual Studio Online and with TFS 2013 Update 2, you can choose Tags as a field to filter on. Also, you can open a query from Excel and bulk modify tags assigned to work items. You can also add tags to work items using Visual Studio.

For on-premises deployments, you can show tags as a column in the query results and you can filter a list based on a tag, however, you can’t add tags as a clause to the filter criteria.

A: In Team Explorer, you can indent (Indent), outdent (Outdent), and drag work items to modify the hierarchy.

Also, you can open a query in Excel or Project to bulk-modify parent-child and predecessor-successor link relationships.

A: To save a query to the Shared Queries folder, get added to the project administrators group.

To add a query as a team favorite, open the Context Menu Icon context menu for the query and add it as a team favorite. You need to be a team administrator to add queries to team favorites.

Email query results list

You can only add shared queries to team favorites, and only if you have team administrator permissions.

A: No. You can only add folders under My Queries and under Shared Queries.

A: Yes. From TWA and the Results list for a query, choose the send mail icon. From Team Explorer, open the context menu and choose the Send to Microsoft Outlook. Also, you can only send to TFS user accounts as only these accounts can open the linked work items contained within the query.

Send query by email (TWA)

If you can’t send email, you need to configure an SMTP server.

To email a list of query results from Team Explorer, you must have Outlook installed on your client computer.

A: Yes. The easiest way to define a hyperlink is to create a query that matches what you want and then copy the URL for the query. The hyperlink uses the work item query language (WIQL), which resembles Transact-SQL, and matches this syntax:

http:// ServerName : Port/ /tfs/CollectionName/TeamProjectName/q.aspx?pname=Project&wiql=WorkItemQueryLanguage

For example, the following hyperlink lists the ID, title, and state of all bugs that have build number 9.0.30304 defined for the AdventureWorksProject project.

http://AdventureWorks:8080/tfs/ /q.aspx?pname=AdventureWorksProject&wiql==SELECT [System.ID], [System.Title], [System.State] FROM WorkItems WHERE [System.TeamProject]='AdventureWorksProject' AND [System.WorkItemType]='Bug' AND [System.FoundIn]='9.0.30304' http://Server1:8091/tfs/web/wi.aspx?id=9035

A: Yes. From the query editor in Team Explorer, use the File menu to save a query as a .wiq file. When you create a team project, the shared queries are created based on .wiq files defined in the process template.

A: The task board only shows tasks linked to backlog items that have been assigned to an iteration. It’s possible to assign tasks to an iteration but not have them linked to a parent backlog item. These items will show up in the created query, but not show up on the task board itself. TFS runs the query and then applies a few background processes before displaying the task board items.

Show:
© 2014 Microsoft