TFS 2010 – Customizing Work Item Link Types
(This is a re-post of information from the now deprecated blog: “ Teams WIT Tools ”)
(3/2/2010: Updated post. Corrected picture for “Dependency” link type)
With TFS 2010, you can define multiple work item link types. This allows for you to customize link types to match your processes. This blog post is a primer in how to do that.
Quick-start guide on creating a new link type:
Here's how to create a new link type:
- From the command shell, go to “Program Files\Microsoft Visual Studio 10.0\Common7\IDE”
- Run "witadmin.exe exportlinktype /s ServerName /n System.LinkTypes.Dependency /f mylinktype.xml”
- View the mylinktype.xml file that was created. It should look like this:
<?xml version="1.0" encoding="utf-8"?>
<LinkTypes>
<LinkType ReferenceName="System.LinkTypes.Dependency" ForwardName="Successor" ReverseName="Predecessor" Topology="Dependency" />
</LinkTypes>
- Edit the mylinktype.xml file to look like this.
<LinkTypes>
<LinkType ReferenceName="MyLinks.LinkTypes.MyLink" ForwardName="My Successor" ReverseName="My Predecessor" Topology="Dependency" />
</LinkTypes>
NOTE: It is important to change the namespace from “System.” To “MyLinks.” (or some other name), because “System.” Is a protected namespace.
- Run “witadmin.exe importlinktype /s ServerName /f mylinktype.xml
- Go to your Team Explorer and select “Refresh Cache”, or close and reopen your Visual Studio.
The new link item type should now be available to use from your forms.
What is that "topology" field for?
Now, what is that “topology” field in the definition XML. Topology assigns a set of rules that are enforced for that link type. There are four topologies to select from:
Network
Link types of this topology have essentially no rules and no directionality. You can have circular relationships, and the link looks the same from both sides.
Example XML:
<LinkTypes>
<LinkType ReferenceName="MyLinks.LinkTypes.MyRelated" ForwardName="My Related" ReverseName="My Related" Topology="Network" />
</LinkTypes>
Directed Network
Link types of this topology are like Network links, except there is directionality. You can specify a name that appears at each end of the link. In other words, the link looks differently depending from which side you view it.
Example XML:
<LinkTypes>
<LinkType ReferenceName="MyLinks.LinkTypes.MyDependent" ForwardName="My Dependent" ReverseName="My Provider" Topology="DirectedNetwork" />
</LinkTypes>
Dependency
Link types of this topology are like Directed Network links in that they have directionality, but an additional constraint to prevent circular relationships.
Example XML:
<LinkTypes>
<LinkType ReferenceName="MyLinks.LinkTypes.MyPred" ForwardName="My Successor" ReverseName="My Predecessor" Topology="Dependency" />
</LinkTypes>
Tree
Link types of this topology are essentially trees, it enforces a one-to-many relationship and doesn’t allow circularity.
Example XML:
<LinkTypes>
<LinkType ReferenceName="MyLinks.LinkTypes.MyTree" ForwardName="My Child" ReverseName="My Parent" Topology="Tree" />
</LinkTypes>
There you have it. Creating link types in less than 400 words.
Comments
Anonymous
March 01, 2010
For the "Dependency" type I think the image is wrong. Why would the link be forbidden? It isn't circular.Anonymous
March 01, 2010
Thanks for the comment. I have corrected the image.Anonymous
September 20, 2010
Gregg, is it possible to add a custom link type to my Process Template so when I upload the template my Custom Link Types are automatically created for me? Thanks, PieterAnonymous
November 28, 2010
Is possible to remove the linktype ? then how ?Anonymous
November 28, 2010
Oh ! .. sorry .. I got it .. using witadmin deletelinktype :)Anonymous
March 10, 2011
hi greg! i need to put a constrain between two work items...in other words a work item can start only if another work item is in the state Closed. how can i do?Anonymous
March 10, 2011
hi greg! i need to put a constrain between two work items...in other words a work item can start only if another work item is in the state Closed. how can i do?Anonymous
June 15, 2011
Hello We need to customize the LinksControl and add new attribute in it beside Description and Comments attribute. We need to store few other values while creating a link b/w workitems. Can any one help, how we can customize/extend the LinksControl or any workaround for this issue.Anonymous
April 04, 2012
Hi Gregg, I want to create my own LinkType.but I am confused with Reference Name. is reference name is associated with another file?I have one LinkControl,xml file.Anonymous
July 02, 2012
@Raj The Reference name is a fully qualifies namespace for the link. It doesn't matter what you use, but it should be unique. Something like Company.LinkType should work.