How to: Add a Query to a Process Template

A work item query can be run to find specific groupings of work items, such as risks or active bugs. Work item queries are specified in work item query (WIQ) files in the Queries folder under the Work Item Tracking folder, located in the folder where you downloaded your process template. For example, MSF for Agile Software Development defines the Active Bugs query that is specified in the ActiveBugs.wiq file.

The easiest way to create work item query files is in Team Explorer. In an existing team project, use Team Explorer to create all of the work item queries that you need for your process. Then use the following procedure to save each work item query to a .wiq file. For more information on creating work item queries, see How to: Add New Work Item Queries.

Required Permissions

To perform this procedure you must be a member of the Team Foundation Administrators group.

If the necessary security permissions are set explicitly, then you must have the View server-level information permission set to Allow and the Manage process template permission on the team project set to Allow. For more information, see Team Foundation Server Permissions.

To save a work item query to a .wiq file

  1. In Team Explorer, right-click the query and choose View Query.

  2. From the File menu, choose Save <name of query> [Query] As.

  3. In the Save Query As dialog box, choose the File option, and enter a location and filename for the WIQ file. Alternatively, click Browse, enter a filename, browse to the location to save the file, and click Save.

  4. Click Save.

  5. Copy the file to the \WorkItem Tracking\Queries folder, located in the folder where you downloaded your process template.

    Note

    You must edit the WIQ file in a text editor and remove the <TeamFoundationServer> and <TeamProject> elements that associate the query with a specific Team Foundation Server and team project. Otherwise, the query will not work properly if the process template is uploaded to a different Team Foundation Server. Alternatively, use macros where possible so that your query does not contain the explicit name of the current team project or any other explicit values specific to a certain environment.

Example

To include the work item queries in the process template, create one or more tasks in the workitems.xml file, which you can find in the \WorkItem Tracking folder, located in the folder where you downloaded your process template. Use the <Query> element to specify the correct work item query file.

<Query name="Active Bugs" fileName="WorkItem Tracking\Queries\filename.wiq" />

The following example shows how to specify a task that creates the All Scenarios work item query in MSF for Agile Software Development. This task cannot run until all of the work item types are created.

<task
   id="Queries"
   name="Stored Query Definitions"
   plugin="Microsoft.ProjectCreationWizard.WorkItemTracking"
   completionMessage="Queries uploaded"
   completionDescription = "Processing the stored queries used by work item tracking">
   <dependencies>
      <dependency taskId="WIs" />
      <dependency taskId="WITs" />
   </dependencies>
   <taskXml>
      <QUERIES>
         <Query name="All Scenarios" fileName="WorkItem Tracking\Queries\AllScenarios.wiq" />
         ...
      </QUERIES>
   </taskXml>
</task>

See Also

Tasks

How to: Verify Work Item Type Definition Changes

Concepts

Work Item Types

Work Item Instances