Cannot create link between WorkItem and Server object in TFS 2012

431 views Asked by At

I'm trying to create a link from a work item to the current server version of a file in TFS via the API. I can do it within Visual Studio (2012) so I know it's possible. However when I try and do it via code it fails with TF201038: Linked item does not exist or access is denied. See Work Item Permissions for Links (http://go.microsoft.com/fwlink/?LinkId=75624) for more details.

The link doesn't really give me any helpful suggestions.

The workitem and the object are both objects that I've created and just gone and got out of the VCS. The link type I'm trying to create exists because I've checked against the WorkItemLinkTypes.

I've created the correct ends for the link types and added a new related link to the workitem.

It's only when I do a WorkItem.Save that it gives me the error.

The workitem isn't access denied, isn't read only or anything odd like that.

Have I missed something ?

1

There are 1 answers

1
Giulio Vian On BEST ANSWER

I guess you are using the wrong link type.

You should not use the WorkItemLinks property nor the WorkItemLink class. Instantiate an ExternalLink object and add it to the WorkItem.Links collection instead.

You can find sample code at TFS2010: How to link a WorkItem to a ChangeSet.