So far in this chapter, you have examined the guts of a work item, and have a basic understanding of how you can create your own work item, and add it to Team Foundation Server. Now it's time to move on to how you actually interact with the work item tracking system daily. You do this using Team Explorer, and specifically the Work Items folder located in your Team Project. From here you can do anything you need to concerning the work item tracking system: create a new work item, open an existing work item, retrieve lists of work items, and build custom views of work items, just to name a few.
As usual, you can modify all these options, and make them work for you as you need them to.
Creating a new work item is easy. Simply right-click the Work Items folder, Select Add Work Item, and then the work item type you want to create. For example, to create a new task work item, select Task. This opens the task for you to fill out as shown in Figure 11-5.
Notice how certain fields are filled in for you automatically, like the Assigned To, State, and Reason fields. Enter a title and save the work item. When you save the work item, it will be assigned an ID. Remember this ID, as you will come back to it later.
If you do not fill in all the required fields, you will not be able to save the work item.
All work item information is stored in the data tier of the Team Foundation Server. To access this information, you create queries, similar to SQL queries. These queries are stored with the Team Project, and can be set where the entire team can access them, or they can be made private to a particular user.
Figure 11-6 shows the Team Explorer window for the Chp11WIT Team Project. Notice that there are two folders: Team Queries and My Queries. The Team Queries folder contains all the work item queries that are accessible by the entire team. The My Queries are your personal queries for this Team Project.
You can retrieve a particular work item by using the work item id number. Simply right-click the Work Items folder, and select Go To Work Item. Enter the work item id and it pulls up the details of the work item. This provides a quick way to review a specific work item's information, without having to run a larger query against the database.
As you can see from Figure 11-6, there are several pregenerated queries for you. These include the following:
Active Bugs - Returns all active bugs for current team project
All Issues - Returns all work items for the current team project that have been marked as an issue
All Quality of Service Requirements - Returns all active quality of service requirements for current team project
All Scenarios - Returns all active scenarios for current team project
All Tasks - Returns all active tasks for current team project
All Work Items - Returns all work items for the current team project that have not been closed
My Work Items - Returns all work items for the current team project that have not been closed and are assigned to you
My Work Items for All Team Projects - Returns all work items across all team projects that have not been closed and are assigned to you
Project Checklist - Returns all work items for the current team project whose exit criteria has been set to yes
Resolved Bugs - Returns all bugs for the current team project that have been resolved
Untriaged Bugs - Returns all active bugs for the current team project that do not currently have a triage state set
These queries are created for you automatically by the process model you selected when you created the team project.
You'll notice in Team Explorer, under the Team Foundation Server name, there is a folder called My Favorites. You can add a query to your favorites by right-clicking on it and selecting Add to My Favorites. This makes the queries you use frequently easily accessible.
To view the logic behind a query, right-click query and select View Query. Do this for My Work Items, as shown in Figure 11-7.
In this view, you can see the where clause of the query, as well as the query results in table format. You can modify the where clause, or double-click a row in the results view to open the actual work item.
Be careful though. If you modify a query located in the Team Queries folder, that query will be changed for everyone who has access to the Team Project. Modifications to Team Queries should be limited to those people who are in charge of the team project. For individual users, it makes more sense to use the My Queries folder.
When a new team project is created, the My Queries folder is empty, which makes sense. This folder is designed to hold any queries you create for this team project, which can only be accessed by you. This allows you to make as detailed a query, or any many queries, as you like, while providing you with a secure, safe place to store and access them.
To create a new query, simply right-click the My Queries folder and select Add Query. This opens a view very similar to Figure 11-7, but with the where clause of the query initially empty. Using this query builder, you can easily build a query to retrieve the work item information in which you are interested.
Almost any field from the work item type can be used in the query. When you select the Field column, you will see a list of possible fields from which to choose. Depending on the field you select, you may be provided with a list of possible values. For example, if you select the Assigned To field, you will be presented with a list of all the users in Team Foundation Server. Little touches like this make utilizing the work item tracking system more efficient.
The query builder works like most query builders, so you should grasp it rather quickly. However, you may have already noticed one potential issue. If you are using the Assigned To field to retrieve some work item information and you hard-code a user ID into it, if you want to share that query with other users, they will have to modify it appropriately. While this is not an earth-shattering problem, it can be annoying. Microsoft anticipated that, and has developed a set of macros that allow you to make queries that are more generic. You can actually see these macros in use in the different pregenerated team queries, and in Figure 11-7.
Here are three of the most commonly used macros:
@me - Substitutes the windows account name of the user running the query
@Project - Substitutes the project name of the project containing the query
@today - Substitutes midnight of the current date on the machine running the query. You can also add or subtract days from it, such as @today–4 or @today+7.
And, of course, in keeping with the make-it-work-like-you-want-it-to-work theme, you can create your own custom macros as well, and store them in Team Foundation Server for everyone to use.
There are three different views for a work item query. Figure 11-7 already showed you one view of query results, where the query builder is displayed at the top of the window, and table of query results is displayed at the bottom. Now let's look at the other two views.
To actually run a query, just double-click it, or right-click the query and View Results. Running the My Work Items Query, shown in Figure 11-8, shows the table of work items retrieved in the top of the window, and the specific details of the select work item below.
You can double-click a row to view the query full screen, similar to Figure 11-5.
You can also right-click the table, and select which columns are displayed and the sort order for the columns. You can select several work items and print them all at once. Take this screen and modify it so that it works best for you. If you make any changes to how you view the query, these changes will be saved with the query.
The beauty of having all the work item information stored in a database is that every change to the work item can be tracked. This allows you to easily view a history of the work item, from when it was created, to any modifications made to it, to when it is finally closed.
All the pregenerated work item types have a history tab, which displays the history information for the work item. You can also add this history tab to any work item types you create, instantly enabling you to use the same functionality, without having to do any major coding or jump through any hoops.
Developers live and breathe in Visual Studio. But managers are sometimes a different breed. Many managers like their Microsoft Excel or Microsoft Project, and don't want to be taken out of their comfort zone. Team Foundation Server takes this into account by allowing managers to open work item information in Microsoft Excel or Microsoft Project.
Doing this is simple. In Team Explorer, right-click the work item query you wish to view. From the context menu, select Open in Microsoft Excel or Open in Microsoft Project. This opens the results of that query in the tool you selected. Figure 11-9 shows the results of opening the All Work Items query in Microsoft Excel.
Now anyone comfortable with Excel can easily view and update this information. The beauty of this is that any changes you make in the spreadsheet can be synched back up with Team Foundation Server. For example, select a row and change the Assigned To field to a different person. Now, under the Team menu option, select Publish Changes. This pushes any changes in the spreadsheet back to the Team Foundation Server. If you now go back into Team Explorer, and pull up the work item you just changed, you will see the Assigned To field has been changed to the new value.
All the power of the work item tracking system, with the ability to use it in the tool of your choice, allows you to put the power back into the hands of your users, instead of the users being slaves to a particular tool.