Search code examples
wiqlazure-devops-rest-api

Creating a VSTS Extension, using WIQL query to grab work item data, can I grab Activity field data?


I'm creating a Visual Studio Team Services extension that in it's current iteration is supposed to display child tasks for development, testing, etc. that were added to a work item. I build a WIQL query to get these tasks and some data about them.

In VSTS (and TFS), tasks have an Activity field, which I want, to differentiate between the different types of tasks (development, testing, etc.). However, I'm finding with the below WIQL query I create, I get the following error: TF51005: The query references a field that does not exist. The error is caused by «[System.Activity]». Is there a way I can get access to the Activity field for those tasks? Or is it just not supported currently?

SELECT [System.Id], [System.WorkItemType], [System.Title], 
       [System.Activity], [System.State] 
FROM WorkItemLinks 
WHERE (Source.[System.TeamProject] = 'someProjectID' 
    AND Source.[System.Id] = someWorkItemID
    AND Source.[System.State] <> 'Removed') 
    AND ([System.Links.LinkType] = 'System.LinkTypes.Hierarchy-Forward') 
    AND (Target.[System.WorkItemType] = 'Task') 
MODE(Recursive)

Working through this I discovered https://marketplace.visualstudio.com/items?itemName=ottostreifel.wiql-editor, which has helped make it alot easier debugging my WIQL query. I highly recommend it to anyone who is new to working with WIQL.


Solution

  • I looked some more and discovered my answer, apparently Microsoft.VSTS.Common.Activity is the field you want to reference to get the activity for the task. I found it here: https://www.visualstudio.com/en-us/docs/work/track/query-numeric. Looks like there's some more information there about some data you can grab, like Microsoft.VSTS.Scheduling.StoryPoints. However it's definitely not a complete list, and I wasn't able to find one. Feel free to comment on this if you know of a complete list of references to use to grab anything you want about a work item!