Accessing work item history from API

How do I access the work item history from the API?

I want to traverse the history of the work item by entry if possible.

If it is not possible, a string with all the history will help too.

Thanks

[826 byte] By [PabloRincon] at [2007-12-20]
# 1

Hello

You can fetch the work item of a particular revision from Work Item Store and then access the History Field to get the History. A sample code is here:

WorkItem wi1 = WIStore.GetWorkItem(wi.Id);

wi1.Open();

wi1.Title = testTitle + "Random Text";

wi1.Description = testDesc + "Random Text";

wi1.History = "Random Text";

int revisionNumber = wi1.Revision;

wi1.Save();

WIStore.RefreshCache();

WorkItem wi2 = WIStore.GetWorkItem(wi.Id, revisionNumber + 1);

String historyText = wi2.History;

Please let me know if you need any additional information on this.

Thanks

Sagar

SagarSura at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Team Foundation Server - Work Item Tracking...
# 2

I'm thinking that Pablo is asking how to get all of the information from the History tab -- not just the text entered from "Type your comment here." (i.e. the WorkItem.History property).

You could iterate through the WorkItem.Revisions property and then iterate through the Fields collection for each revision, and display any values that changed between adjacent revisions.

If you want to know the timestamp of the revision and the user that made the change, it looks like you'd use rev["Changed Date"] and rev["Changed By"].

-Larry

LawrenceParker at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Team Foundation Server - Work Item Tracking...
# 3

here some example:

foreach(Revision rev in wrkitem.Revisions)

{

foreach(Field f in rev.Fields)

{

Console.WriteLine("{0} = {1}\n",f.Name,f.Value);
}
}

ogiepogi at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Team Foundation Server - Work Item Tracking...
# 4

Thanks for your answers.

I was able to traverse the revisions in the way described on the last post.

Thanks again,

Pablo

PabloRincon at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Team Foundation Server - Work Item Tracking...
# 5
no problem :)
ogiepogi at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Team Foundation Server - Work Item Tracking...
# 6

There is OriginalValue property on fields as well, so you can use something like

foreach(Field f in rev.Fields)
{
if(!Object.Equals(f.Value, f.OriginalValue))
{
Console.WriteLine("{0}: {1} -> {2}", f.Name, f.OriginalValue, f.Value);
}
}

History control creates Field Change tables when clicking on expand button.

ValeryTolkov at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Team Foundation Server - Work Item Tracking...

Visual Studio Team System

Site Classified