IMPORTANT: This version of Sitefinity CMS is out of support and the respective product documentation is no longer maintained and can be outdated. Use the version selector to view a supported product version.
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.
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.
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.
Back To Top
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important