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!

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

4 Comments

+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.
@SirCrispalot how do we remove the grouping ?
@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.
Thanks just noticed that inside the pink box we have to take the cursor eaxctly over the braces. Thank you :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.