3
votes

Context

If you copy a TFS Work Item, the history tab of the copy gets an entry saying "Copied from Feature 364057" with a hyperlink to "Feature 364057". Following the link opens the Work Item in Visual Studio (as expected!).

Looking behind, the HTML is as follows: Copied from <a href="x-mvwit:workitem/364057">Feature 364057</a>.

If you are interested, you can try yourself using this C# code to read out the changed fields of revisions of a Work Item to get the above HTML code:

private static void PrintRevisions(WorkItem workItem)
{
    foreach (Revision revision in workItem.Revisions)
    {
        Console.WriteLine($"Fields of Revision {revision.Index} | TagLine = {revision.GetTagLine()}");
        PrintFields(revision.Fields);
    }
}

private static void PrintFields(FieldCollection fields)
{
    foreach (Field field in fields)
    {
        Console.WriteLine($"{field.Name} | {field.ReferenceName} = {field.Value}");
    }
}

Problem

If I insert exactly the same HTML in the Description tab of a Work Item, I get the following message when I want to follow that link: Unsafe link


Question 1: Does anybody know why it is possible to open that type of link from the History tab and not from the Description tab? Maybe there is a Visual Studio setting related to the message?


Question 2: Is there another way to create links to other Work Items, in the Description tab, that open the Work Item in Visual Studio (and not in the Internet Browser)?

Please do not refer to the functionality of creating links/relationships, e.g. via the All Links tab. I explicitly want to open links to other Work Items from within the Description field.

1

1 Answers

-1
votes

@Question1: I found the following: Microsoft states that within the "New work item tracking experience" you can link a work item in the discussion tab by typing '#' (see New work item tracking experience). I linked an item with this method and then analyzed the JSON object which I requested via REST API. I thought I will get the same link structure as with copying:<a href="x-mvwit:workitem/364057"> but instead I got:

<a href=\"https://{MyServer}/tfs/_permalink/_workitems/edit/1234?collectionId=1234&amp;projectId=1234\" data-vss-mention=\"version:1.0\">Feature 1234: _Template Feature</a>&nbsp;<br>

Maybe you can provide a link with the second structure (worked for me), but generally it seems that its only for the discussion tab.