Work Item History field isn’t just a Text field that shows all the changes in a specific work items, it’s a collection of Revision object. Each time you save a Work Item a new revision object is been create and repsent the Work Item Latest values.
You can use the History to get pvious values from Fields, Links and Attachments history.
In this post I’ll show how to get Work Item revision list and display the Fields of specific revision.
Download Demo Project
private void btnConnect_Click(object sender, RoutedEventArgs e) { TeamProjectPicker tpp = new TeamProjectPicker(TeamProjectPickerMode.NoProject, false); if (tpp.ShowDialog() != System.Windows.Forms.DialogResult.OK || tpp.SelectedTeamProjectCollection == null) { btnFetch.IsEnabled = txtWitId.IsEnabled = false; return; } tfs = tpp.SelectedTeamProjectCollection; store = new WorkItemStore(tfs, WorkItemStoreFlags.BypassRules); btnFetch.IsEnabled = txtWitId.IsEnabled = true; }
Using WorkItemStore object you can get the work item, the work item object contains a Revisions collection that will allow you to navigate inside the work item history.
private void FetchWorkItemHistory() { if (string.IsNullOrEmpty(txtWitId.Text)) return; if (!int.TryParse(txtWitId.Text, out _workitemId)) return; WorkItem wit = store.GetWorkItem(_workitemId); listRevs.ItemsSource = wit.Revisions; }
You can also get the Work Item from specific Revision:
WorkItem wit = store.GetWorkItem(_workitemId, rev.Index);