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?
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:
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:
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>
Related
I would like to get a list of any WorkItems I modified in TFS using TFS query builder. Including status changes I made, "assinged to" changes and including those I made posts in History.
That looks to me like pretty basic and logical query, but couldn't fiugre out how to do that.
We're using the TFS web interface, but I guess it's identical to the query builder in VS's Team Explorer.
You can get all the work items you modified with the "Changed By" field (with “Was Ever” = your username):
This query returns all the work items you modified any field (State, Assigned To, etc.), but you can't create a query to get only work items when you changed them only specific fields.
There are APIs to query using an existing wiq file.
I want my app to create actual wiq files in a shared folder - which can be accessed outside my app too. But I cannot find any API to do that.
What's that mean for wiql files here?
WIQL is Work Item Query Language, if you mean create a query with WIQL and save the query as a file, then no any API to do that, however you can try below steps:
Create a query with the Query Editor, save the query.
Open the query in Visual Studio --> Edit Query
File -> Save {Query}[Editor] as...
Then you can open and edit the saved *.wiq file with text editor, then save/copy to a shared folder...
Reference below articles:
Export a query
Quickly generate Work Item Query for use in the TFS API
Yes, there is an API, see Create a query in the REST API.
The POST body should contains the WIQL Query and the name for it.
{
"name": "All Bugs",
"wiql": "Select [System.Id], [System.Title], [System.State] From WorkItems Where [System.WorkItemType] = 'Bug' order by [Microsoft.VSTS.Common.Priority] asc, [System.CreatedDate] desc"
}
To invoke the REST API, I suggest you to use a Microsoft library instead of writing all the code yourself, e.g. https://learn.microsoft.com/en-us/vsts/integrate/concepts/dotnet-client-libraries.
When I import data from Sql Server in Power Query, I can paste a query to be executed against the database. But later when I want to edit this query in Workbook Queries > Edit > Advanced Editor, I get something like this:
let
Source = Sql.Database("server", "database", [Query="select#(lf)#(tab)*#(lf)from dbo.SomeView va#(lf)join dbo.SomeTable rm#(lf)#(tab)on rm.CatId=va.CatId#(lf)where 1=1#(lf)#(tab)and Month between 1501 and 1510#(lf)#(tab)and rm.Id in (1,2,3)"])
in
Source
Please note that I'm using *, but with explicit column names this would look even worse.
I'd like to be able to see the query in a readable form, then copy it, execute in Management Studio, change something and paste back to Power Query. I know I could be using views as a source, or not using newlines and indentation, but that's not my point.
Any ideas on how to edit SQL in "normal" form? Or maybe I'm missing some hidden option.
EDIT:
In case I'm not the only person in the world having problems finding this option, it's in:
Power Query > Launch Editor > View > Query Settings > Applied Steps > Source > Gear icon
Thanks Alejandro!
If you click on the gear icon next to Source in the Query Settings pane you'll get a dialog with the SQL query in a readable form.
Here's an illustration that complements the accepted answer.
Suppose I have an Open Data Table definition at a publicly accessible location such as http://example.com/mytable.xml:
<?xml version="1.0" encoding="UTF-8"?>
<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd">
...
</table>
How can I run a query (e.g. show tables) against this definition? Is there some way to import the table definition into the YQL console directly?
(The example doesn't explain how to get YQL to actually read the table definition--it leaves this bit as an exercise to the reader...)
One or more tables can be manually imported by using the use statement:
use "http://example.com/mytable.xml" as mytable;
desc mytable;
If you have many tables, or want to reuse a bunch of them for different queries, then create a YQL environment file, and use this in the console or the actual query URLs with the env GET parameter (docs).
See Invoking an Open Data Table Definition within YQL for full details.
I've been tasked with creating a small application to query a customer database, and map its bug entries into TFS. All is well with nearly everything so far. My customer db queries work, and I can easily create a new WorkItem and place it into TFS. But I'm stuck trying to populate an HtmlFieldControl with the contents of a WorkItem Template we use for bugs. I've found the XML for this template stored on our NAS, which I assume was created through TFS PowerTools. The file has a .wt extension. Once I'm done with this, the contents of the Value element should appear in the HtmlFieldControl.
<Template xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<FieldValues>
<FieldValue>
<ReferenceName>Microsoft.VSTS.TCM.ReproSteps</ReferenceName>
<Value>...</Value>
</FieldValue>
</FieldValues>
<WorkItemType>Bug</WorkItemType>
<TeamServerUri>...</TeamServerUri>
<TeamProjectName>...</TeamProjectName>
<Description />
</Template>
I can't find any documentation on this particular element anywhere, so I have no clue how it could fit into the existing bug WorkItemType.
The template is stored as such on TFS:
It should appear in the Work Item Form itself like this:
If there is no way to accomplish this, how could I take a peak at the XML of this populated form to see what I'm supposed to do?
When creating a new WorkItem and populating fields, I found that there was a custom field in place called "Repro Steps," so I fed in the template as such:
workItem.Fields["Repro Steps"].Value = templateText;
Works like a charm.