none
Microsoft TeamFoundation TestManagement Client - QueryAssociatedWorkItems not picking up all workitems RRS feed

  • Question

  • Hello 

    I could not find the correct category for the question, its actually the service for TFS. 

    I am trying to access all the work items associated with a test case in TFS pro grammatically using the Class in 

    Microsoft.TeamFoundation.TestManagement.Client and method QueryAssociatedWorkItems()

    But this returns only some work items associated not all, at times it does not return at all. 

    I am trying to fetch all the bugs associated with the test case, but it does not pick all. 

    I am using the right class? 

    Thursday, September 27, 2018 5:53 PM

Answers

  • Can you share your source - how you are calling this method? This method can be called on TestResult or TestResultCollection.

    Meantime, can you try something as below - 

    //Get the work item service
    workItemStore = (WorkItemStore)teamProjectCollection.GetService(typeof(WorkItemStore));
    
    string queryString = "Select * From WorkItems Where [System.Id] = " + <workItemId>;
    
    // Create and run the query.
    Query query = new Query(workItemStore, queryString);
    WorkItemCollection results = query.RunQuery();
    
    WorkItem wt  = (WorkItem)results[0];
                    
    if(wt.Links.Count > 0)
    {
        LinkCollection links = wt.Links;
        //Here probably you can loop through links and display them
    }
    


    Thanks,
    Vivek Bansod
    Blog | MSDN | LinkedIn
     

    • Marked as answer by paulalwin91 Friday, September 28, 2018 8:09 PM
    Friday, September 28, 2018 6:29 AM

All replies

  • Can you share your source - how you are calling this method? This method can be called on TestResult or TestResultCollection.

    Meantime, can you try something as below - 

    //Get the work item service
    workItemStore = (WorkItemStore)teamProjectCollection.GetService(typeof(WorkItemStore));
    
    string queryString = "Select * From WorkItems Where [System.Id] = " + <workItemId>;
    
    // Create and run the query.
    Query query = new Query(workItemStore, queryString);
    WorkItemCollection results = query.RunQuery();
    
    WorkItem wt  = (WorkItem)results[0];
                    
    if(wt.Links.Count > 0)
    {
        LinkCollection links = wt.Links;
        //Here probably you can loop through links and display them
    }
    


    Thanks,
    Vivek Bansod
    Blog | MSDN | LinkedIn
     

    • Marked as answer by paulalwin91 Friday, September 28, 2018 8:09 PM
    Friday, September 28, 2018 6:29 AM
  • Hello Vivek,

    This is exactly what I was looking for. The WorkItemStore gives me all the links and the bugs therein!

    Regards,

    Paul

    Friday, September 28, 2018 8:10 PM