60607

TFS 2010 work item - Work item links

When a user opens a bug from a test case, I need to check if the test case is linked to a requirement item and if so I need to link the bug to the requirement item.

How can I know this information?

I use following piece of code:

WorkItemLinkCollection links = _workItem.WorkItemLinks; foreach (WorkItemLink link in links) { }

but I don't know how to get the link type and link id.

Answer1:

WorkItemLink is an abstract base class. ExternalLink, HyperLink, and RelatedLink inherit from it so the link instance will be one of those types. So, check the type of your instance or test it with 'is'. You can also get the RegisteredLink property which gets the friendly name of the link type.

For more info see http://msdn.microsoft.com/en-us/library/microsoft.teamfoundation.workitemtracking.client.link(v=vs.80).aspx

Concerning the id that it's related to, each type is related to something different. For example, the RelatedLink type has a RelatedWorkItemId property which returns the id of the workitem that this workitem is related to. The source id is the id of the workitem that the link collection is on.

http://msdn.microsoft.com/en-US/library/microsoft.teamfoundation.workitemtracking.client.relatedlink_members(v=VS.80).aspx

But, a hyperlink link isn't related to another workitem - it has a location property to get the hyperlink location as a string.

http://msdn.microsoft.com/en-US/library/microsoft.teamfoundation.workitemtracking.client.hyperlink_members(v=VS.80).aspx

Recommend

  • e.preventDefault prevent click
  • Django admin link to image via ImageField
  • Why Setter Property is not applied on Hyperlink?
  • UIWebView contextual menu while displaying PDF content
  • Remove HyperLinks from text
  • WPF - Tooltip on a disabled hyperlink with an embedded TextBlock element
  • R code to open path associated with point on scatterplot
  • Cannot clear session using javascript in jsp
  • Run macro when clicking on hyperlink that directs to another worksheet
  • Optimizing Google Sheets .appendRow()
  • How could I get the link of an specific sheet with Google script?
  • Azure AD B2C Custom Policy
  • Join with Three Tables
  • TFS 2010 work item - Work item links
  • ASP.NET: Setting the Style of an HTML element Programatically
  • How to display formatted HTML data in kendo ui grid column
  • Why isn't page jQuery .focus event changing background-color style to green in Google Chrome af
  • Use a ListProperty or custom tuple property in App Engine?
  • How to programatically add a hyperlink to a cell in a worksheet using office-js?
  • IIS 7.5 404 Error for .PDF files
  • Microsoft Chart Controls for Microsoft .NET Framework 4.0
  • Is mp4 stream able with ffserver?
  • Python/Javascript: WYSIWYG html editor - Handle large documents fast and/or design theory
  • IE10 strips out hashtag from the URL
  • Create a link to a web page that runs a Javascript function on the page
  • Enumerating Controls on a Form
  • Extract All Possible Paths from Expression-Tree and evaluate them to hold TRUE
  • XSLT foreach repeating nodes to flat
  • List images(01.png) and descriptions(01.txt) from directory
  • D3 nodes and links from JSON with nested arrays of children
  • jquery mobile loadPage not working
  • VB.net deserialize, JSON Conversion from type 'Dictionary(Of String,Object)' to type '
  • How to delete a row from a dynamic generate table using jquery?
  • json Serialization in asp
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • How do I configure my settings file to work with unit tests?
  • How to stop GridView from loading again when I press back button?
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • Binding checkboxes to object values in AngularJs