Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Limit Version History

Status
Not open for further replies.

camusa

Technical User
Sep 13, 2002
80
US
I was told that there is a registry key that can be changed to limit the amount of versions that are kept when version history is enabled on a document library in windows sharepoint services. Does anybody know which one?

TIA,

Chris
 
I dont know about a reg key but in the SDK there is an example where an eventhandler is created for this task:
Ms Windows SharePoint Services\Programming Tasks/Programming with the Object Model\Handeling Document Library events

This is the eventhandler mentioned there:

Code:
private int maxVersions = 5;

void IListEventSink.OnEvent(Microsoft.SharePoint.SPListEvent listEvent)
{
    /* TODO: ***** PROVIDE YOUR IMPLEMENTATION HERE ****
    Get the credentials (User_Alias, Domain, Password) that this event sink instance should run as
    and initialize the wic object by calling the CreateIdentity method*/

    WindowsImpersonationContext wic = CreateIdentity(User_Alias, Domain, Password).Impersonate();

    if ((listEvent.Type == SPListEventType.Update) ||
        (listEvent.Type == SPListEventType.CheckIn))
    {
        SPWeb site = listEvent.Site.OpenWeb();
        SPFile file = site.GetFile(listEvent.UrlAfter);
        int nDocVersions = file.Versions.Count;

        while ((maxVersions > 0) && (nDocVersions > (maxVersions - 1)))
        {
            file.Versions.Delete(0);
            nDocVersions = file.Versions.Count;
        }
    }

    wic.Undo();
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top