TFS & Visual Studio ALM – by Neno Loje

(formerly Team System, VSTS)

Using rich HTML descriptions instead of plain text

January 11th, 2009 · 6 Comments · 9672, Team Foundation Server, TFS Extensibility, TFS Process Customization, TFS Tips and Tricks, TFS Work Item Tracking, VSTS


Allow rich HTML formatting in description fields of the MSF Agile process template.

Note: The MSF CMMI process does support HTML formatting by default. In order to use it you have to enable the formatting toolbar (see Step 6 below).

Work Item Customization

Step 1: Add a new HTML description field

Since the System.Description field is defined of type string as opposed to type HTML we need to create a new field:



Step 2: Change the work item layout

Use your own HTML field instead of System.Description


Step 3: Refresh Work Item cache

Right-click "Work Items" in Team Explorer and select "Refresh".


Step 4: Enable the formatting toolbar

Right-click on the Visual Studio toolbar, find and click "Formatting":


A new toolbar will appear:



Click into the description field and use the toolbar to format your input:



Optional Step 5: Copying the old descriptions to the new HTML field

It would be a pity to loose the existing descriptions so let’s write a small utility using the Team Foundation Object model to copy the "old" descriptions to the new HTML field:

static void CopyOldDescriptions()
    // TODO: Change these values:
    string tfsName = "servertogo";
    string tfsProjectName = "WorkItemCustomization";
    string tfsHtmlDescriptionFieldName = "DescriptionHtml";
    string tfsWorkItemType = "Task";

    using (TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer(tfsName))
        WorkItemStore wit = (WorkItemStore)tfs.GetService(typeof(WorkItemStore));
        WorkItemCollection result = wit.Query(String.Format("SELECT [System.Id] FROM WorkItems WHERE [System.TeamProject] = '{0}' AND [System.WorkItemType] = '{1}'", tfsProjectName, tfsWorkItemType));
        List<WorkItem> affectedWorkItems = new List<WorkItem>();
        foreach (WorkItem wi in result)
            if (wi.Description.Length > 0)
                // Set new description
                string value = (string)wi[tfsHtmlDescriptionFieldName];
                if (String.IsNullOrEmpty(value))
                    wi[tfsHtmlDescriptionFieldName] = wi.Description.Replace("\n", "<br>");
                    wi[tfsHtmlDescriptionFieldName] += "<br><p>Old description:</p><p>" + wi.Description.Replace("\n", "<br>") + "</p>";

                // Delete old description
                wi.Description = String.Empty;


        if (affectedWorkItems.Count > 0)
            MessageBox.Show("Items updated: " + affectedWorkItems.Count);
            MessageBox.Show("Nothing to do.");

Happy formatting. :-)



6 Comments so far ↓

  • Tzvika

    Hello and Thanks.
    in Visual Studio it works ok.

    But in Web Access there is a problem:
    in History tab, i see the HTML code itself.

    do you know what can i do?


  • thomas engen

    How do I change the field so it automaticilly expand and get larger in the Microsoft Visual Studio 2008 Team System Web Access? It has an fixed size.

  • John

    I am using a template derived from CMMI. For me the Description data type is “Plain Text” and there’s no formatting toolbar. Was this changed in TFS 2010? (Which we’re not using yet.)

    What happens to the web access Search if we make this change? Presumably it won’t be able to search on this text ??

  • neno

    John, this was not changed in TFS 2010. System.Description still a plain text field.

    The newest template, VS Scrum 1.0, is using a different field for it’s descriptions named Microsoft.VSTS.Common.DescriptionHtml.

    Your assumption is correct. Team Web Access only searched System.Description – you will not be able to seach your new custom field with the built-in search functionality by default.

  • John

    Thanks, Neno – it’s a shame the search is so limited.

    It would be nice if the next version of tfs could allow us to customize how the search works. (IE which columns are searched and which are returned.) I’ve downloaded an extension for TFS which allows me to search visual studio and I can define the exact query I want to use – it would be great to have something like that in web access search. It’s also annoying how the batch editing and the little context menu (create copy/related item etc.) is missing from the search. Hopefully that was added in tfs 2010.

  • isabel Pereira

    I need to bulk edit hundreds of product backlog items and the export to excel has the descripiton html field as read only… sure would be nice to have it as an editable field.

Leave a Comment