You can create a query that retrieves a set of work items
that meet specific conditions.
About this task
When you create a query, you specify the conditions and the
work item properties to show in the query results. You can create
a query for personal use or for shared use with a team.
Procedure
- On the main menu, click Work Items,
and then click Create Query.
- If you plan to save the query, in the query editor, type
a name for the query.
- On the Conditions tab, click the
plus sign icon, and then select an attribute to use as a query condition. For example, to query on all work items without a Parent
link, from the attributes list, select Parent.
Then, in Step 4, set
the attribute condition.
Tip: You can also
create queries for archived attributes and attribute values. By default,
archived attributes are not included in the attribute list. To display
archived attributes, click the Show archived values icon.
- Click Add condition,
and then specify the value or condition that must be met for the attribute. For example, to query on all work items without a Parent link,
set the attribute condition for the Parent attribute
to do not exist. As another example, for the
Due Date attribute, you can specify a relative date, such as 15 days
from now, or a specific date. If you select or specify multiple values,
the values are joined by OR statements, which means that the condition
is true for any of those values. You can add groups of conditions
by clicking Add OR Condition. For each group,
click All must match or Any can
match. Use AND when all of the conditions you specify
must be met for the query to return a work item. Use OR when any one
of the conditions must be met. Queries for string-based fields, such
as Summary and Description, are not case-sensitive.
- Optional: To specify input variables for an
attribute condition, in the upper-right corner of the attribute condition
area, click the Enable Input of Condition Values when Query
is Run icon. When you run the query, the Assign
Values to Query Parameters wizard opens. In the wizard,
select the values for every input variable and run the query.
- Click the Details tab. Enter a description
of the query so that other users can understand which work items the
query returns.
- By default, new queries are private. To share a query with
members of a team, click and then select a team. To share a
query with a specific user, click and then select the user.
Tip: If
you change a shared query, the changes apply to other users who you
share the query with. If you delete a shared query, that query is
no longer available to users who you shared the query with.
- Click the Column Display tab. In
the Result Columns section, use the Add Column and Remove controls
to specify the attributes to show as column headings in the query
results. To rearrange the columns, use the Up and Down controls.
To specify the order that results are shown in, click Add
Sort Column and then select an attribute. You can set
the sort direction to ascending or descending for each attribute.
Note: You are able to create a query that includes empty fields: for example, text fields without
content can be included in your query.
- Optional: To show parent and child relationships
in query results:
- On the Column Display tab, click Add
Column.
- In the Select Attributes window,
click Show Links.
- Navigate to and select the Parent or Child attributes,
and then click OK. The next time that you run
the query, the query results table contains the parent and child work
items.
- To run the query, click Run.
Tip: In the filter text field, you can filter the
query results by ID or Summary.
- To save the query, click Save. To
save a copy of the query, click Save Copy.
Results
If you do not share the query, it is in your
My
Queries list only. If you share the query with a user,
the query is in your
My Queries list and in
the user's
Individually Shared folder in the
Shared
Queries folder. If you share the query with a team, the
query is in the team area folder in the
Shared Queries folder.