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.

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Get started with Integration Hub | Sitefinity Cloud | Sitefinity SaaS

This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.

Web Security for Sitefinity Administrators

This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?