21

I need to find TFS work items related to a certain topic in our project. For that purpose, I tried querying the work items using the query builder in Visual Studio.

Since there are multiple terms I wish to search for, I imagined a query like this:

WHERE (
Priority > 300 AND 
(Title.Contains('Dog') OR Title.Contains('Cat') OR Title.Contains('Hamster')))

Now, according to http://msdn.microsoft.com/en-us/library/dd286638.aspx (Section And/Or) one should be able to do that like so:

    | Priority|   >    | 300
And | Title | Contains | Dog
Or  | Title | Contains | Cat
Or  | Title | Contains | Hamster

But... that does not work as described: as far as I can see, this is treated like

(Priority > 300 AND Title.Contains('Dog')) OR Title.Contains('Cat') OR Title.Contains('Hamster')))

Now that is a bit of a problem for me, because apart from a 'Priority' criterion I also have 8 additional criteria that need to apply to all the matches (Date, State, etc.). And I have not only three possible title matches, but around ten. So that multiplies and I would end up with a query that is terribly long and mostly redundant.

.. or, am I missing something here? Is there another way to express those statements? Or is there even another way to query TFS work items, like another tool?

Thanks!

Efrain
  • 3,248
  • 4
  • 34
  • 61

1 Answers1

34

You need to "Group" your Title clauses together to get the query you expect. Select the three "Title" clauses, Right Click and select "Group Clauses".

Group Clauses

Here's a snip of a query I created in VS2012 to do this, but it's the same in 2010.

It will only find work items with a Priority >4 and a Title containing either Crash, Error or Working.

Query with Grouped Clauses

DaveShaw
  • 52,123
  • 16
  • 112
  • 141
  • 3
    +1 This was driving me crazy! You can do this in the web UI as well - by checking the boxes alongside each clause and clicking the *Group selected clauses* button at the top of the column. – Sir Crispalot Aug 31 '17 at 13:37
  • @SirCrispalot how do we remove the grouping ? – Gaurav Khurana May 02 '18 at 09:45
  • 1
    @Gauravkhurana I just tried this - for the web UI, you just click the icon in pink highlight which spans the clauses you have grouped. It will ungroup them. – Sir Crispalot May 02 '18 at 12:51
  • Thanks just noticed that inside the pink box we have to take the cursor eaxctly over the braces. Thank you :) – Gaurav Khurana May 03 '18 at 03:08