2
votes

I create work items through the TFS api.

var type = project.WorkItemTypes["Bug"];
var workItem = new WorkItem(type)
{
    History = "Created by OneTrueError incident #" + dto.OneTrueErrorIncidentId,
    Title = dto.Title,
    Description = dto.StackTrace,
};
workItem.Fields["Activity"].Value = dto.Activity;
workItem.Fields["Repro Steps"].Value = dto.StepsToReproduce;
workItem.Links.Add(new Hyperlink(someBaseUri + "/issue/" + dto.OneTrueErrorIncidentId));
workItem.Save();

At a later point I want to be able to fetch a specific work item by querying on a Hyperlink that I attached when creating the work item.

I can't figure out how to write that query. All examples I've found regarding links are for links to other work items or TFS resources. I have had no luck trying to modify those examples.

So how can I find a specific workitem using WIQL and a specific Hyperlink.Location?

1
I suggest you to use some structured tag in order to do filtering: you can query tags but not links.Giulio Vian

1 Answers

1
votes

Unfortunately, it's not able to directly use hyperlink url info in WIQL. You could only use Hyperlink Count field which returns the number of hyperlinks that are defined for the work item.

Reference Name=System.HyperLinkCount, Data type=Integer

As a workaround you may have to get a list of worktiems with links and go through all returned info to match the url that your attached when creating the work item. Then get the work item.