Revision history of content items

Delete revision history for content items

The following code sample demonstrates how to delete the entire revision history for a content item:

In the code above, you get an instance of the VersionManager class. Next, you call the GetItemVersionHistory method of the version manager and pass the ID of the content item. As a result, all revision history changes for that specific content item are queried. To delete these changes, you iterate through the queried changes and call the DeleteChange method of the version manager by passing the ID of each of the changes. Finally, you save the changes of the operation.

Delete revision history up to a specific point in time

The following code sample demonstrates how to delete the revision history of a content item up to a specific date:

In the code above, you get an instance of the VersionManager class. To delete the revision history up to a specific date, you call the TruncateVersions method of the version manager and pass the ID of the content item and the date up to which you want to delete the revision history. Finally, you save the changes of the operation.

Delete all but a specific number of revision history changes

The following code sample demonstrates how to delete all but an exact number of revision history changes, for example, keep just the last 10 modifications you made to a content item and delete all other changes:

 

In the code above, you call the GetItemVersionHistory method of the version manager and pass the ID of the content item. As a result, all the revision history changes for that specific content item are queried. Next, you order the queried revision history changes by Version number. During this step, you apply the filtering conditions defining how many revision history changes to skip. When calling the TruncateVersions method of the version manager, you pass the ID of the content item and a Version number. As a result, all revision history changes with version smaller or equal to the specified number are deleted.

Want to learn more?

Sign up for our free beginner training. Boost your credentials through advanced courses and certification.
Register for Sitefinity training and certification.

Was this article helpful?