Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8316291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:19:44+00:00 2026-06-08T21:19:44+00:00

I am trying to use the TFS API to scan through all my bug

  • 0

I am trying to use the TFS API to scan through all my bug workitems, and see if there are any with no associated test cases. I was thinking about using bug.Fields[26].Value == 0 to see how many Related Links there are, but I am not sure if test cases are the only things that are considered related links.

If there are no test cases associated with the bug, I want to create a test case for it. I already know how to create a test case in general, but not one that is associated with an existing bug.

Can someone tell me how to do these things? Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T21:19:45+00:00Added an answer on June 8, 2026 at 9:19 pm

    Any work item that is linked to your Bug is considered a RelatedLink. Check here for the available types that derive from Link and also this SO-post by @bryanmac.

    With the following you should be able to retrieve the type of each related work item of your bug 123456.

    using System;
    using Microsoft.TeamFoundation.Client;
    using Microsoft.TeamFoundation.WorkItemTracking.Client;
    
    namespace WorkItemLinksOfAWorkItem
    {
        class Program
        {
            static void Main()
            {
                TfsTeamProjectCollection teamProjectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://TFSURI"));
    
                var workItemStore = (WorkItemStore)teamProjectCollection.GetService(typeof(WorkItemStore));
    
                var workItem = workItemStore.GetWorkItem(123456);
                LinkCollection links = workItem.Links;
                foreach (Link link in links)
                {
                    if (!(link is RelatedLink))
                        continue;
    
                    var relLink = link as RelatedLink;
                    var relatedWI = workItemStore.GetWorkItem(relLink.RelatedWorkItemId);
                    Console.WriteLine(relatedWI.Id+" "+relatedWI.Type.Name);
                }
            }
        }
    }
    

    (I had originally found the base of these sources in Scrum Dashboard)

    In order to generate a new Test Case for your Bug 123456 you could try something like:

    var workItemTypes = workItemStore.Projects["TeamProjectName"].WorkItemTypes;
    var workItem = new WorkItem(workItemTypes["Test Case"]) {Title = "Programmatically constructed via TFS-SDK"};
    
    var relatedLinkToBug = new RelatedLink(123456);
    var links = workItem.Links;
    links.Add(relatedLinkToBug);
    
    workItem.Save();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use the TFS API to retrieve the latest code from
I am trying to use TFS team build, but can't find any decent startup
I have installed TFS Power Tools and I am trying to use the powershell
i'm trying use facebook API to upload photo in my fan page. I downloaded
I am trying to create a report using TFS 2010 database to show all
I am trying use the new server side plug-in feature for TFS 2010. (I
I am trying to use TFS Integration Platform to migrate my project A on
I'm trying to use Cruise Control .NET with TFS. What is the best way
I am trying to come up with best practices regarding use of TFS source
I'm trying to create a CLI command to have TFS check out all files

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.