This documentation is archived and is not being maintained.

Work Item Revision History

Every time you commit a Client, you create a new Revision for that WorkItem. The latest Revision of a WorkItem reflects its last saved state, whereas previous Revisions reflect the state of the WorkItem at different points in its history. Different Revisions of a WorkItem are akin to different versions of source code on a server.

In this model of work item revisions, the History field requires special handling. This field behaves like a discussion thread. Each reply to the thread is stored in a separate revision of the WorkItem. The work item form shows the aggregated values of all revisions of the history field. When you modify the history field programmatically, the caller can append a new entry to the history thread by setting the field's value in the current revision to the desired text.

Previous entries in the history thread are associated with previous revisions. The latest revision of a WorkItem will have an empty History field value even if the history thread shows text on the WorkItem's form, unless the history value was set explicitly. The samples provide an example of reading and writing to the history field.

The following sample displays the History field for all revisions of a WorkItem.

// Display the History field from all revisions of a WorkItem
Console.WriteLine("WorkItem ID: {0}", workItem.Id);
RevisionCollection revisions = workItem.Revisions;

foreach (Revision revision in revisions)
    String history = (String)revision.Fields["History"].Value;

    if (history != null)
        StringBuilder sb = new StringBuilder(history);

        // The History field is meant to be displayed as HTML.
        // Because this will be displayed on the console, the
        // the HTML paragraph headers are removed.
        sb.Replace("<P>", "");
        sb.Replace("</P>", "");

        Console.WriteLine("Revision {1}: ", workItem.Revision);
        Console.WriteLine("  ChangedDate: " + workItem.Fields["ChangedDate"].Value);
        Console.WriteLine("  History: " + sb.ToString());