Creating a simple Work Item Query

Recently I have had reason to find a number of closed work items and change their status from Closed back to Active for a number of our developers. This is a very straight forward task but it could be made even easier if I could easily find recently closed work items. This posts details the situation I am experiencing and walks you through creating a very simple custom work item query to make things easier when it happens again. 

Scenario

A developer has partially completed the work assigned to him/her in a Work Item and while the code will build, the work defined in the work item is not yet complete. The developer dutifully selects a work item (as required by the check-in policy I have created) and then checks the code into TFS.

Problem

The problem/issue occurs when the developer selects the work item and does NOT change the default Check-in Action from Resolve to Associate after selecting the work item. This effectively closes the work item so when they go back to finish the work, the appropriate work item does not appear for them to select prior to check-in.

What is required is a quick and easy way to see recently closed work items, so you can change the State field from Closed back to Active.

Solution

The solution for this is very simple. Create a custom work item query that displays only those work items that have been closed in the past week. The following steps will take you through the process. While this custom query is a very simple example, take a few moments to see what other options are available in the query designer.

Creating a custom Work Item Query: “Work Items Closed (last 7 days)”

  1. Start Visual Studio 2005 and make sure you can see the Team Explorer
  2. Right-click on My Queries under Work Items in your team project and select Add Query from the context menu as shown in the following screenshot NewWIQuery1</li>

    • Set the following parameters for your query
      And/Or = “And
      Field = “Closed Date”
      Operator = “>”
      ** Value = **“@Today – 7”
      newwiquery2
      </LI>

      • Right click in the area below the query parameters grid and select Run Query from the context menu. If any Work Items have been closed in the current team project in the past week, these will be displayed.
      • Click the Save button on the toolbar to save your query. You should provide a meaningful name such as Closed Work Items (Past 7 days) and then choose if you want to save this query for everyone in the team to see or just you. </p> newwiquery3
        </LI>

        • After saving your query, you will now see it appear in the Team Explorer window ready to be called upon when necessary.</OL>