3

So, it turns out the home page of our site has 670 versions so Im looking at removing or archiving most of them.

In the Sitecore content editor, if I select Remove all versions (plan is to archive needed versions and restore them), the process is long. Running overnight, it deleted around 200 versions as seen in the [History] db table.

Strangely I can see 4 RemovedVersion rows for each version removed in this table with a minute or twos gap between the admin and Anonymous rows so it runs very slow:

                ItemVersion ItemPath                    UserName            TaskStack

RemovedVersion en 209 /sitecore/content/Corporate/Home sitecore\Anonymous [none]

RemovedVersion en 209 /sitecore/content/Corporate/Home sitecore\Anonymous [none]

RemovedVersion en 209 /sitecore/content/Corporate/Home sitecore\admin Sheer

RemovedVersion en 209 /sitecore/content/Corporate/Home sitecore\admin Sheer

1
  • 1
    If you wrap it with a security and event disabler, it should be very quick.
    – Chris Auer
    Commented Mar 10, 2017 at 0:46

2 Answers 2

8

If you use Sitecore PowerShell Extensions you can make this process faster by wrapping it in an EventDisabler

SPE has a Remove-ItemVersion cmdlet that lets you select the language(s) versions and also the max number of recent versions to keep. This means you don't need to archive and restore the needed versions.

This code assumes v4+ of SPE:

New-UsingBlock(New-Object Sitecore.Data.Events.EventDisabler) {
    Remove-ItemVersion -Path master:\content\home -Language "en", "en-GB" -MaxRecentVersions 5
}

You could script this to remove versions on specific items. There is also a -Recurse flag on the cmdlet that will remove versions on the specified item and all child items too.

If you wanted to be able to select an item in the content tree and provide a right click menu option to remove the versions, you could create a module to do this. Here is an example of how to do that.

1
  • Exactly what I needed and still working for Sitecore 8.x
    – Mark
    Commented Feb 18, 2019 at 14:57
0

Spoke to Sitecore about this and they recommended going straight to the database:

DELETE FROM SharedFields WHERE SharedFields.ItemId = 'XXX' DELETE FROM VersionedFields WHERE VersionedFields.ItemId = 'XXX' DELETE FROM UnversionedFields WHERE UnversionedFields.ItemId = 'XXX'

Seems to have worked OK

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.