Creating Work Item Queries

Use queries to locate work items based on the information in the work item form. A simple query might search for work items that contain a specific value in one part of the form, such as all work items assigned to you. More complex queries can search for several values on the form. You create queries by using clauses to refine your query results.

In Team Foundation work item tracking, a query that is specific to work items is called a work item query and is identified by using the file name extension .wiq.

Query Operators

A query operator is used in a query clause when you create a work item query. Each query clause is composed of a field name, query operator, and value. The query operator determines which operation to apply when it determines whether a work item should be included in the results.

The following table lists the query operators available in Team Foundation work item tracking.

Query Operator

Description

Applicable Field Types

=

Returns a work item if the field matches the specified value.

Number, Text, Date, Tree

<>

Returns a work item if the field does not match the specified value.

Number, Text, Date, Tree

>

Returns a work item if the field is greater than the specified value.

Number, Text, Date

<

Returns a work item if the field is less than the specified value.

Number, Text, Date

>=

Returns a work item if the field is greater than or equal to the specified value.

Number, Text, Date

<=

Returns a work item if the field is less than or equal to the specified value.

Number, Text, Date

Contains

Returns a work item if the field contains the specified text value.

Text

Does Not Contain

Returns a work item if the field does not contain the specified text value.

Text

In

Returns a work item if the field matches any value in a specified set. For example, comparing the ID field to the set of values 100, 101, 102 will return work items 100, 101, and 102.

Number, Text, Date, Tree

Was Ever

Searches the history of the field. Returns the work item if any one of the historical field values match the specified value.

Text, Date

Under

Searches a tree field and returns any work items under the node specified by the value.

Tree

Not Under

Searches a tree field and returns any work items that are not under the node specified by the value.

Tree

Query Variables

Query variables enable you to generate the value for a query, which enables you to create dynamic queries that search for the current date, current user, or current project.

The following table lists the query variables available in Team Foundation work item tracking.

Query Variable

Result

@Me

Use the @Me value in the Value column to automatically search for the current user's alias in a field that has user aliases. For example, if you want to return a list of work items opened by you, you would set the Field column to Activated By, the Operator column to =, and the Value column to @Me.

@Project

Use the @Project value in the Value column for any field that references team projects to search in the current team project. For example, if you want to return a list of all the active work items for the currently selected project, you would set the Field column to Team Project, the Operator column to =, and the Value column to @Project.

@Today

Use the @Today value in the Value column for any date field to search for the current date. The query enters the current date whenever it is run. You can also modify the @Today variable by subtracting days. For example, to find all items activated in the last week, you would set the Field column to Activated Date, the Operator column to >=, and the Value column to @Today - 7.

In This Section

See Also

Other Resources

Adding and Modifying Work Items