Monday, July 15, 2013

How to use WIQL to query for work items in TFS 2012 via the URL

These days I spend a large amount of time in TFS 2012. 

In TFS 2008 and 2010 users could use the q.aspx page to run a query using WIQL as defined by the 2010 WIQL spec (http://msdn.microsoft.com/en-us/library/bb130306(v=vs.100).aspx). Ken O' Bonn has a great post on this at http://blogs.msdn.com/b/kenobonn/archive/2009/05/28/how-to-link-directly-to-tswa-2008-or-2010-beta1-work-items-or-queries.aspx

However in TFS 2012 the URLs for everything changed and I was unable to find any information on how to accomplish the same task. How can you provide a URL to users that queries for work items without writing and saving a query to the TFS server. 

The key is I don't want to save a query to TFS.   

So after some trial and error I found the way!

http://<ServerAddress>:8080/tfs/<TPC Name>/<Project>/_workitems#_a=query&wiql=<WIQL>

An example:

http://tfstest:8080/TPC1/project1/_workItems#_a=query&wiql=select id, [System.areapath] from workitems

The WIQL for 2012 is defined at http://msdn.microsoft.com/en-us/library/bb130306.aspx#language