Search code examples
tfstfs-sdk

Revert (or undo saved changes) a WorkItem to an older version in TFS API


I am looking to create an "undo" mechanism for a TFS work item using the TFS API - this will undo committed changes. Basically, after saving new data (also using the API) to the work item, I would like the option to revert the WorkItem back to the previous version.

Pseudo code something like this...

1)Get current Work Item for Id:xxxxxx

2)Get "revision id" of this latest work item and store in "PreviousRevId"

3)Modify field values

4)Save

5)For whatever reason we don't want these changes any more (domain logic as to reasons are excluded for brevity)

6)Revert to old revision ("PreviousRevId") and make it the current (latest) revision


Solution

  • Have a look at the Work Item History Visualizer i created. By taking the work item Id, you can pull out the history of all work item fields.

    http://geekswithblogs.net/TarunArora/archive/2011/08/21/tfs-sdk-work-item-history-visualizer-using-tfs-api.aspx

    But this will only help you get the information, rest you'll have to build your own control to build the revert functionality.

    EDIT: Also worth checking this visual studio extension ** http://visualstudiogallery.msdn.microsoft.com/d127b275-b7b6-4504-b01e-58b4a010ff53 This lets you see the work item as it was on the historic date. Giving you the baseline affect you are after. HTH