Events in Microsoft Sharepoint 2007

MS provides very limited documentation on the sequence of the events, or what event(s) a particular action will incur. Here is my findings:

I didn’t handle xxxING events. Here are all xxxED events:

Folder operations:

  • Add a folder: ItemAdded. No ItemUpdated.
  • Delete a folder: very strange, ItemDeleted is not called. ItemDeleting is called. If folder contains files, files do not fire events. Update:ItemDeleted may have been called. But since the GUID is no longer valid so there is little use to catch this event.
  • Update: If folder name is actually changed, both ItemFileMoved and ItemUpdated will be called. Otherwise, only ItemUpdated will be called. Note: even there are files under this folder, only one ItemFileMoved event will be fired for the folder.
  • Restore from recycle bin: Note: neither folder nor the files within it fires ItemAdded or ItemUpdated event.

File operatins:

  • Add file: ItemAdded. ItemUpdated and ItemCheckedIn will follow if choose to Checkin at the second step. When upload multiple documents, only ItemAdded will be called because there is no 2nd step window at all.
    When you add a new item, only the ItemAdding event is raised. However, in cases where Explorer View is used, both the ItemAdding and ItemUpdating events are raised. In such cases the ItemUpdating event always occurs after the ItemAdding event occurs.
  • Checkin: ItemCheckedIn and ItemUpdated. There is no fixed order which one is called first. They are simultaneous.
  • Update: If file is not changed, only ItemUpdated. Otherwise, ItemFileMoved will also be called. No fixed order.
    • Special note on file name change (same to folder name change): in one case, the ItemUpdated event handler throw exception in the middle due to a ‘File not found’ error. Please look out for this scenario.
    • Be careful when making changes in this event, which will incur next ItemUpdated event, which will also incur next. Put some logic there before making changes.
    • If the file is renamed in ‘Explorer view’ like a regular Windows file, only ItemFileMoved event is fired.
  • Delete: ItemDeleting. See note about folder delete above.
  • Delete from recycle bin: no event caught.
  • Restore from recycle bin: ItemAdded
  • Checkout: ItemUpdated/ing is NOT called (ItemCheckedOut should also be called which I didn’t verify). Note: however the version number increases when checking out (can be found in properties), not until check in. I’m a little puzzle since if version # changes, ItemUpdated should be called.
  • Discard checkout: ItemUpdated/ing is not called.

Good reference: http://blogs.msdn.com/brianwilson/default.aspx

Advertisements
This entry was posted in Events and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s