locked
Event handler for deletion of document versions in MOSS 2007? RRS feed

  • Question

  • There is apparently no event handler for the deletion of document versions in MOSS 2007.

    How can we handle such events (i.e. to prevent the deletion of particular versions, or to delete referenced documents after version deletion)?

    thanks in advance
    Thursday, October 23, 2008 10:13 AM

Answers

  • Versions are stored as SPListItemVersion objects, and not SPListItems .. and the SPListItemVersion.Delete() method is the one you are trying to trap.

    Unfortunately, this does not correspond to any changes to the SPListItem itself, and therefore doesn't fire any events.

    At the moment, there is no way to trap that event.

    If you want to trap a version restore event .. thats different (and I have code to do that if you are interested).


    regards
    Martin Hatch
    MCPD .Net Web Development
    MCTS WSS 3.0 | MOSS 2007
    Visit my Blog
    Thursday, October 23, 2008 10:57 AM
  • HOWEVER ... there is a Permission Level for deletion of versions.

    If you go to the following:
    Site Settings --> Advanced Permissions.
    go to Settings --> Permission Levels.
    you will see a list of the various permission levels available (Full Control / Read / Contribute ... etc).

    You can add your own permission levels, or modify existing ones.
    If you do either you will see a checkbox under List Permission which reads:

    Delete Versions - Delete past versions of a list item or document

    I think that is what you are looking for :) No need for code :)
    regards
    Martin Hatch
    MCPD .Net Web Development
    MCTS WSS 3.0 | MOSS 2007
    Visit my Blog
    Thursday, October 23, 2008 11:02 AM

All replies

  • Versions are stored as SPListItemVersion objects, and not SPListItems .. and the SPListItemVersion.Delete() method is the one you are trying to trap.

    Unfortunately, this does not correspond to any changes to the SPListItem itself, and therefore doesn't fire any events.

    At the moment, there is no way to trap that event.

    If you want to trap a version restore event .. thats different (and I have code to do that if you are interested).


    regards
    Martin Hatch
    MCPD .Net Web Development
    MCTS WSS 3.0 | MOSS 2007
    Visit my Blog
    Thursday, October 23, 2008 10:57 AM
  • HOWEVER ... there is a Permission Level for deletion of versions.

    If you go to the following:
    Site Settings --> Advanced Permissions.
    go to Settings --> Permission Levels.
    you will see a list of the various permission levels available (Full Control / Read / Contribute ... etc).

    You can add your own permission levels, or modify existing ones.
    If you do either you will see a checkbox under List Permission which reads:

    Delete Versions - Delete past versions of a list item or document

    I think that is what you are looking for :) No need for code :)
    regards
    Martin Hatch
    MCPD .Net Web Development
    MCTS WSS 3.0 | MOSS 2007
    Visit my Blog
    Thursday, October 23, 2008 11:02 AM