Example work item queries
Updated: July 15, 2016
Use the following examples to better understand how to query for work items using the query editor.
Use = to find current assignments. Use Was Ever to list items based on past assignments.
To filter on items assigned to someone who belongs to a TFS group, use the In Group operator.
You can use the In Group or Not In Group operators to filter a query based on several values that are members of a group, or that are not members of a group. Examples of groups are TFS groups and work item categories.
To filter work items based on the category they belong to, use the In Group operator. For example, the following filter criteria will return all work items that are in the current team project, assigned to the team member, and defined as belonging to the Bug Category.
Use Contains and Contains Words to list items that partially or exactly match the words or phrase that you enter.
Choose Contains or Does Not Contain to search against exact or partial matches of a word or phrase. Choose Contains Words or Does Not Contain Words to search against an exact phrase or to use the wildcard character, *. These operators use the full-text search index.
Team Foundation automatically indexes all long-text fields with a data type of PlainText and HTML and the Title field for full-text search. For restrictions, see 814c2dca-cf8f-44bf-bba1-a5d8e293fc05#full_text for server and collation requirements.
You can find work items that have an undefined field value by using the not operator (<>). For example, the following example will find all work items of type Task whose Activity field is blank.
To find work items that were closed but then reactivated, you can create a query similar to the one shown. By specifying the Changed Date field, you can focus on reactivations that occurred today, yesterday, or in the last week.
You can also use the Activated By and Activated Date fields.
Add this clause to filter items defined in two different team projects.
Separate project names with the list separator that corresponds to the regional settings defined for your client computer, for example, a comma (,).
The following example shows a dependent linked query that returns items with dependencies on work managed by other teams and other team projects. Use this query to see all dependent work items that link to active Product Backlog Items or Bugs that have not been removed, closed, or completed. Only those dependent work items that are under a product area other than the Phone Save\Phone Customers are returned.
Why this works:
Removing the Team Project = @Project clause enables all dependent linked work items that match the filter criteria to be listed, no matter which team project they belong to in the collection.
Grouping each of two clauses returns all Product Backlog Items on the backlog or in progress, and the second grouped clause returns all Bugs on the backlog or in progress.
Grouping the two clauses with the OR operator at the start of the second clause returns work items that match either of the two filter criteria.
Choosing the Only return items that have the specified links returns only top-level work items that have dependencies.
Choosing Return links of any type returns all linked work items that match the filter criteria for linked work items, in this case, returning all work items that are not under the Phone Saver\Phone Customers area path, and aren't completed or removed.
The following image shows the query results that are returned.
A: Yes. For the Field, choose History and for the Operator field, choose Contains Words or Does Not Contain Words.
Enter the full text for the word that you want to search. The History field is indexed for full-text search. If you enter only a partial word, the query will not return work items that contain the full word. For example, if the History field contains the phrase reproducible behavior and you search for repro, the work item will not be found. However, if you search for the complete word reproducible, the work item will be found. You can also search for the string with a wild card, such as repro*.
Also, common words are ignored. The search engine ignores words that are defined as stopwords. For more information, see the following page on the Microsoft Web site: Stopwords and Stoplists.