Last day I was querying the work items in TFS to track the status of some of the work items. Usually I used to query the work items (Bugs, Tasks etc.) which are assigned to me. However, last day I needed to query the work items which are assigned to couple of other team members as well. I was able to easily add all the clauses in the query except for the "Assigned To" where I had to do a logical OR operator. Let's take a look at what my query looked like and how I got it working :)
So, basically I wanted the following output using the above query:
"List of all the Work Items which are Assigned To
either of my 2 team members (2nd
& 3rd Assigned To
clauses in the above screenshot), which are not in a Closed State
(They can be in Active, Resolved etc. states)".
Here is a pseudo code which is equivalent of the query in the above screenshot.SELECT [All Types of Work Items]FROM [One or More TFS Backend Database Tables]WHERE[Work Item Assigned To] = "1st Team Member"OR [Work Item Assigned To] = "2nd Team Member"AND [Work Item State] <> "Closed"
But I wanted my query to be something like this:SELECT [All Types of Work Items]FROM [One or More TFS Backend Database Tables]WHERE( [Work Item Assigned To] = "1st Team Member" OR [Work Item Assigned To] = "2nd Team Member")AND [Work Item State] <> "Closed"
Now, as we can see that the output which I wanted as stated above, can be achieved using the above query. And as we can see that, the difference between the above two queries is the presence of brackets in the 2nd query which makes it logically correct.
But I was not able to achieve the equivalent of the 2nd query in TFS. After doing some research, I figured out that there is an option to Group Clauses
in Work Item queries. Select the Clauses which you want to group (Hold shift key and select multiple clauses present one after the other in a sequence), right click and select Group Clauses
from the context menu as shown below:
Once the clauses are grouped, then the TFS Work Item query looks something like this.
Now, in case we need to remove those brackets (grouping) then we just need to select the same set of clauses, right click and select Ungroup Clauses from the context menu as shown below.
It's as simple as that !!!Reference
: How to: Group or Ungroup Work Item Query Clauses on MSDN