'Retrieve the WIQL of a saved query created in TFS

I have created a query in TFS interactively using the web interface. Now I want to get the WIQL that it is using.

The only way I know how is to call the RESTful api, and pass $expand=wiql. Is there an easier way? Ideally from the interactive web interface?



Solution 1:[1]

You can use Chrome's "Developer Tools" (under "More Tools") click the Network tab and run the TFS query. You'll see the query item in the list of items. Click on the query item and you'll see the WIQL code in the view pane.

Example: enter image description here

Solution 2:[2]

Doesn't seem like you can do it in the Web Access. You can however do it in Visual Studio (if you have it).

Open the Query and then Edit it, now if you do File, Save as... you can then save the query as a .wiq XML file, that will include the WIQL:

save as dialog

Example content:

<?xml version="1.0" encoding="utf-8"?>
<WorkItemQuery Version="1">
    <TeamFoundationServer>https://----.visualstudio.com/defaultcollection</TeamFoundationServer>
    <TeamProject>Test Agile</TeamProject>
    <Wiql>SELECT [System.WorkItemType], [System.Title], [System.State], 
    [Microsoft.VSTS.Scheduling.StoryPoints], [System.IterationPath], [System.Tags] 
    FROM WorkItemLinks 
    WHERE Source.[System.WorkItemType] in group 'Microsoft.RequirementCategory' 
</WorkItemQuery>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 kmote
Solution 2