Hi. Today I am going to write about how to Purge old versions in Tridion.
Tridion 2011 has Purge tool which allows you to delete old versions of items. You probably have seen and used it.
Here is a simple example how to use this method via Tom.Net
Tridion 2011 has Purge tool which allows you to delete old versions of items. You probably have seen and used it.
You can find "PurgeOldVersions" method in session.SystemManager class.
This method can be called only bt Administrator. In order to use PurgeOldVersion APi you have to create your own PurgeOldVersionsInstruction.
Like other instructions ,to which you already get used, that Tridion has, it has properties that you have to specify. Here are a list of properties:
Like other instructions ,to which you already get used, that Tridion has, it has properties that you have to specify. Here are a list of properties:
- VersionsToKeep - set how many versions we must keep.
- Recursive - set how deep we should do our purge.
- KeepVersionsModifiedAfter - specify date and keep versions which are going after this date.
- KeepVersionsWithinDaysBeforeLastCheckIn - specify days within last modification to keep versions.
- Containers - specify publications(repositories) and organizational items (only folders and structure groups) in which we can peform purge. If another item pushed to this collection, InvalidActionException will be raised. If input value = null or empty enumeration we have no restrictions for search location and process it on all items in System.
- MaxResolvedVersioneditemsCount - considering, that our search can return a big amount of items we can set max number of items which we can select for purging during this iteration of our functionality. Default value = 0 (Select all items without count restriction).
- DefaultMaxResolvedVersionedItemsCount- Upper limit(and default value) of items, which can be purged during one purging iteration. By default value is equal to 100.000.
Here is a simple example how to use this method via Tom.Net
using (Session session = new Session(user))
{
{
PurgeOldVersionsInstruction instruction = new PurgeOldVersionsInstruction(session)
{ Recursive = false,
VersionsToKeep = 10,
KeepVersionsModifiedAfter = new DateTime(2011,7,28,23,17,0),
KeepVersionsWithinDaysBeforeLastCheckIn = 1,
MaxResolvedVersionedItemsCount = 40
VersionsToKeep = 10,
KeepVersionsModifiedAfter = new DateTime(2011,7,28,23,17,0),
KeepVersionsWithinDaysBeforeLastCheckIn = 1,
MaxResolvedVersionedItemsCount = 40
};
StructureGroup folder =
(StructureGroup)session.GetObject("tcm:2-4-4");
(StructureGroup)session.GetObject("tcm:2-4-4");
List<IContainer> list = new List<IContainer>();
list.Add(folder);
instruction.Containers = list;
session.SystemManager.PurgeOldVersions(instruction);
}
That's great news. I remember having to work on the purge tool back in the day, and ending up doing remedial work on the UI. Part of the problem was that we had to support a screen resolution that you'd laugh at these days - hence those tabs - sorry folks!
ОтветитьУдалитьMaybe now the old purge tool can be given a dignified exit. :-)
Is this exposed in the Core Service too? We're not supposed to use TOM.NET anymore for this type of tools...
ОтветитьУдалить[Sorry, I didn't check it yet, just wondering if you know by heart]
N
Hi Nuno. Yeap indeed you are not suppose to use TOM.net. There is no such Api for Core Service, but It probably will be in a next version.
УдалитьNice. One point we've seen on the TridionWorld forum is we need to be a user with the right permissions and rights to use the Purge Tool (or any of the Tridion APIs or tools).
ОтветитьУдалитьI teased a colleague that of course you need authorization with an API (in that chat it was the Core Service). Otherwise anyone with the right access (or creative hacking) can destroy production content.
Thanks for sharing, I know of the tool, but have never been in role that let me run it!