The Ramblings of Two Microsoft .NET Developers, TFS, and Visual Studio ALM Guys --- "Yes, we are both named Ed."

Grouping Conditional Clauses in Work Item Queries



So, I came across something pretty interesting when I was making a work item query today that I've wondered for a while.  I can't believe I just came across it today.

OK - Just for some background on what I was trying to do:  I wanted to get a team query made that returned all of the bugs for my team.  The only problem is that our department supports all of our products for mainly builds & installers (among other things) and it causes the Area Paths that we look at to be pretty much all over our TFS server.  Usually you would just want all the bugs for a particular product and you can use the UNDER operator for the Area Path field.  I need to use multiple condition clauses using the UNDER operator.  I knew that the Work Item Query Language (WIQL) had a way for putting parenthesis around the conditionals in the WHERE clause.  (The WIQL syntax is very similar to T-SQL if you haven't ever seen it before.)  For example, here's part of a sample WIQL query that I was going after....

SELECT [System.Id], (Other Fields) FROM WorkItems WHERE [System.WorkItemType] = 'Bug'  AND  [System.State] <> 'Closed'  AND  ([System.AreaPath] UNDER 'NetAdvantage\.NET\Installers'  OR  [System.AreaPath] UNDER 'NetAdvantage\.NET\ASP.NET\Builds'  OR  [System.AreaPath] UNDER 'NetAdvantage\.NET\WinForms\Builds'  OR  [System.AreaPath] UNDER 'NetAdvantage\WPF\Builds'  OR  [System.AreaPath] UNDER 'NetAdvantage\WPF\Installers'  OR  [System.AreaPath] UNDER 'TestAdvantage\QTP\WinForms\Builds'  OR  [System.AreaPath] UNDER 'TestAdvantage\QTP\WinForms\Installers'  OR  [System.AreaPath] UNDER 'TestAdvantage\RFT\WinForms\Builds'  OR  [System.AreaPath] UNDER 'TestAdvantage\RFT\WinForms\Installers')

My problem was - how do I put parenthesis in the query using the Work Item Query Editor? (UI in Visual Studio)

 

However, I remember reading Brian's post yesterday about the new Alerts Editor (which by the way is totally awesome and immediately adds value to the product without waiting for the next major release) and thought, I wonder how they did that in the UI with the alerts XPath queries because I know you can't get very good alerts without the ability to group the XPath query conditionals.  Let me steal an image from Brian's post with a little editing showing off a grouping of condition clauses:

Alert Definition with Grouped Conditions

I thought to myself, hmmmm... that grid looks pretty similar to WIQ Editor grid that exists today in Team Explorer 2008 and started searching everywhere for the "group" tool button (since there is not a toolbar above the grid.)  I found it.  It's in the context menu whenever you select multiple rows.  Seriously, I can't believe I haven't ever seen it before.  I guess I don't usually write very complex work item queries :)

Grouping of Conditions in Work Item Query Editor

 

Have fun writing some useful queries for yourself and your team now!

 

Ed B.

Posted in TFS | VSTS


Name
E-mail
(will show your gravatar icon)
Home page

Comment (Some html is allowed: a@href@title, b, blockquote@cite, em, i, strike, strong, sub, sup, u) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

[Captcha]Enter the code shown (prevents robots):

Live Comment Preview