Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio: Query TFS Work Items: AND/OR Logic doesn't work?

Tags:

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!

like image 665
Efrain Avatar asked Oct 24 '12 10:10

Efrain


People also ask

How do I run a VST query?

To open, view, and run queries in Visual Studio 2019, you need to Set the Work Items experience to the legacy option. From the Team Explorer home page, choose Work Items. To open a query, open the context menu for the query (right-click with your mouse), and choose View Results. Or, double-click the query to open it.

How do I give access to shared queries in Azure DevOps?

Set permissions on a shared query You can set permissions by opening the permissions dialog for the specific query. Choose the actions icon and select Security. Change the permissions so that the team member or group can't edit, delete, or change permissions for the query.


1 Answers

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

like image 168
DaveShaw Avatar answered Sep 29 '22 10:09

DaveShaw