Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds

Work Item Querying

Save for later
  • 540 min read
  • 2015-04-07 00:00:00

article-image

In this article by Dipti Chhatrapati, author of Reporting in TFS, shows us that work items are the primary element project managers and team leaders focus on to track and identify the pending work to be completed. A team member uses work items to track their personal work queue. In order to achieve the current status of the project via work items, it's essential to query work items based on the requirements.

This article will cover the following topics:

  • Team project scenario
  • Work item queries
  • Search box queries
  • Flat queries
  • Direct link queries
  • Tree queries

(For more resources related to this topic, see here.)

Team project scenario

Here, we are considering a sports item website that helps user to buy sport items from an item gallery based on their category. The user has to register for membership in order to buy sport products such as footballs, tennis rackets, cricket bats, and so on. Moreover, a registered user can also view/add sport-related articles or news, which will be visible to everyone irrespective of whether they are anonymous or registered. This project is mapped with TFS and has a repository created in TFS Server with work items such as user stories, tasks, bugs, and test cases to plan and track the project's work.

We have the following TFS configuration settings for the team project:

The following figure shows the project with TFS configuration and setup:

work-item-querying-img-0

Work item queries

Work item queries smoothen the process of identifying the status of the team project; this helps in creating a custom report in TFS. We can query work items by a search box or a query editor via Team Web Access.

For more information on Work Item Queries, have a look at following links:

There are three types of queries:

  • Flat queries
  • Direct link queries
  • Tree queries

Search box queries

We can find a work item using the search box available in the team project web portal, which is shown in the following screenshot:

work-item-querying-img-1

You can type in keywords in the search box located on top right of the team project web portal site; for example master, will result in the following work items:

work-item-querying-img-2

The search box content menu also has the ability to find work items based on assignment, status, created by, or work item type, as shown in the following screenshot:

work-item-querying-img-3

The search box finds items using shortcut filters or by specifying keywords or phrases, specific fields/field values, assignment or date modifications, or using the equals, contains, and not operators.

For more information on search box filtering, have a look at http://msdn.microsoft.com/en-us/library/cc668120.aspx.

Flat queries

A flat query list of work items is used when you want to perform the following tasks:

  • Finding a work item with an unknown ID
  • Checking the status or other columns of work items
  • Finding work items that you want to link to other work items
  • Exporting work items to Microsoft Office, Microsoft Excel, and Office Project for bulk updates to column fields
  • Generating a report about a set of work items

As a general practice, to easily find work items, a team member can create Shared Queries, which are predefined queries shared across the team. They can be created, modified, and saved as a new query too.

The following steps demonstrate how to open a flat query list and create a new query list:

  1. In the team project web portal, expand Shared Query List located on the left-hand side and click on the My Tasks query, as shown in the following screenshot:

    work-item-querying-img-4

  2. The resulting work items generated by the My Tasks query will be shown in the Work item pane, as shown in the following screenshot:

    work-item-querying-img-5

  3. As there are now three active tasks and two new tasks, we will create the My Active Tasks flat Query. To do so, click on Editor, as shown here:

    work-item-querying-img-6

  4. Add a clause to filter work items by Active State:

    work-item-querying-img-7

  5. Now click on the Save Query as… icon to save the query as My Active Task:

    work-item-querying-img-8

  6. Enter the query name and folder as appropriate. Here, we will save the query in the Shared Queries Folder and click on OK:

    work-item-querying-img-9

  7. Click on Results to view the work items for the My Active Tasks query and it will display the items, as shown in the following screenshot:

    work-item-querying-img-10

  8. Now let's have a look at how to create a query that represents all the work item details of different sprints/iterations. For example, you have a number of sprints in the Release 1 iteration and another release to test an application that's named Test Release 1 that you can find in Team Web Access site's settings page under the Iterations tab, as indicated in the following screenshot:

    work-item-querying-img-11

  9. In order to fetch the work item data of all the sprints to know which task is allocated to which team member in which sprint, go to the Backlogs tab and click on Create query:

    work-item-querying-img-12

    Unlock access to the largest independent learning library in Tech for FREE!
    Get unlimited access to 7500+ expert-authored eBooks and video courses covering every tech area you can think of.
    Renews at €14.99/month. Cancel anytime
  10. Specify the query name and folder location to store the query. Then click on OK:

    work-item-querying-img-13

  11. Then click on the link as indicated in the following screenshot, which will redirect you to the created query:

    work-item-querying-img-14

  12. Click on Flat list of work items and remove all the conditions except the iteration path, as shown in the following screenshot:

    work-item-querying-img-15

  13. Now save the query and run it. Add columns such as Work Item Type, State, Iteration Path, Title, and Assigned To as appropriate. As a result, this query will display the work items available under the team project for different sprints or releases, as indicated in the following screenshot:

    work-item-querying-img-16

  14. To filter work items based on the sprintreleaseiteration, change the iteration path condition for Value to Sprint 1, as indicated in the following screenshot:

    work-item-querying-img-17

  15. Finally, save and run the query, which will return the work items available under Sprint 1 of the Release 1 iteration:

    work-item-querying-img-18

For more information on flat queries, have a look at http://msdn.microsoft.com/en-us/library/ms181308(v=vs.110).aspx.

Direct link queries

There are work items that are dependent on other work items such as tasks, bugs, and issues, and they can be tracked using direct links. They help determine risks and dependencies in order to collaborate among teams effectively.

Direct link queries help perform the following tasks:

  • Creating a custom view of linked work items
  • Tracking dependencies across team projects and manage the commitments made to other project teams
  • Assessing changes to work items that you do not own but that your work items depend on

The following steps demonstrate how to generate a linked query list:

  1. Open My Tasks List from Shared Queries.
  2. Click on Editor.
  3. Click on Work items and direct links, as shown in the following screenshot:

    work-item-querying-img-19

  4. Specify the clause for the work item type: Task in Filters for linked work items:

    work-item-querying-img-20

  5. We can filter the first level work items by choosing the following option:

    work-item-querying-img-21

    The meanings of the filter options are described as follows:

    • Only return work items that have the specified links: This option returns only the top-level work items that have links to work items.
    • Return all top level work items: This option returns all the work items whether they have linked work items or not. This option also returns the second-level work items that are linked to the first-level work items.
    • Only return work items that do not have the specified links: This option returns only the top-level work items those are not linked to any work items.
  6. Run the query, save it as My Linked Tasks and click on OK:

    work-item-querying-img-22

  7. Click on Results to view the linked tasks as configured previously.

    work-item-querying-img-23

For more information on direct link queries, have a look at http://msdn.microsoft.com/en-us/library/dd286501(v=vs.110).aspx.

Tree queries

To view nested work items, tree queries are used by selecting the Tree of Work Items query type.

Tree queries are used to execute following tasks:

  • Viewing the hierarchy
  • Finding parent or child work items
  • Changing the tree hierarchy
  • Exporting the tree view to Microsoft Excel for either bulk updates to column fields or to change the tree hierarchy

The following steps demonstrate how to generate a tree query list:

  1. Open the My Tasks list from Shared Queries.
  2. Click on Editor.
  3. Click on Tree of work items, as shown in the following screenshot:

    work-item-querying-img-24

    Define the filter criteria for both parent and child work items. Specify the clause for work item type: Task in Filters for linked work items. Also, select Match top-level work items first.

  4. We can filter linked work items by choosing the following option:

    work-item-querying-img-25

    To find linked children, select Match top-level work items first and, to find linked parents, select Match linked work items first.

  5. Run the query, save it as My Tree Tasks, and click on OK.

    work-item-querying-img-26

  6. Click on Results to view the linked tasks as configured previously:

    work-item-querying-img-27

For more information on Tree queries, have a look at: http://msdn.microsoft.com/en-us/library/dd286633(v=vs.110).aspx

Summary

In this article, we reviewed the team project scenario; and we also walked through the types of work item queries that produce work items we need in order to know the status of work progress.

Resources for Article:


Further resources on this subject: