5

I have this WIQL...

Wiql wiql = new Wiql()
  {
    Query = string.Format("SELECT [System.Id], [System.WorkItemType], [System.Title], [System.AssignedTo], [System.State]" +
                          " FROM WorkItemLinks" +
                          " WHERE Target.[System.TeamProject] = '{0}'" +
                          " AND Source.[System.Id] = {1}" +
                          " AND [System.Links.LinkType] = 'System.LinkTypes.Hierarchy-Forward'" +
                          " mode(Recursive)", project, startingChildId)
  };

And I want to make it match this TFS Query where all parents of a particular work item are put into a tree as seen below.

enter image description here

My problem is that I'm only getting the child work items from the case that I want the parent work items. How can I traverse up the tree rather than down it? I have already tried switching System.Links.LinkType to the parent relation equivalent, but doing so throws an unsupported error.

Community
  • 1
  • 1
Jacob
  • 323
  • 1
  • 7
  • 16

1 Answers1

8

Check the WIQL below:

select [System.Id], [System.WorkItemType], [System.Title], [System.AssignedTo], [System.State]
 from WorkItemLinks
 where ([System.Links.LinkType] = 'System.LinkTypes.Hierarchy-Forward')
  and (Target.[System.Id] = 4839)
 order by [System.Id]
 mode (Recursive, ReturnMatchingChildren)
a_hardin
  • 4,991
  • 4
  • 32
  • 40
Cece Dong - MSFT
  • 29,631
  • 1
  • 24
  • 39