Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
SDK Documentation
General Reference
Event Fundamentals
 Event Troubleshooting

  Switch on low bandwidth view
Community Content
In this section
Statistics Annotations (0)
Event Troubleshooting

Programming events can cause exceptional behaviors, depending on the contexts in which you implement the event handlers. The following table describes event behaviors related to specific contexts that you might encounter when writing code.

Context Description

Document libraries and content types

You create an .aspx page of a particular content type in a document library, and the page has associated ItemAdding and ItemAdded events, but the events do not fire.

Only default content type properties are present in the Add phase. Additional properties (fields) of the specified content type are added only in the Update phase. Therefore, best practice is to avoid firing Add events with a specified content type ID. Instead, set the content type to the default content type in the Add phase. The content type can subsequently be changed in the Update phase. An alternative is to register the events at the list level.

Document libraries and content types

An ItemAdding event that is bound to a content type fires even when a document that is not of that type is uploaded.

When you first add a document to a library, the content type is always the default content type associated with the list. The content type of the document can be changed during the Update phase and the content type ID is adjusted accordingly.

Document libraries and content types

A request to delete an item through a list form does not have an associated content type ID, but this causes an ItemDeleting or ItemDeleted event to fire on all items, not just on items of a specific content type, even though the event was registered only for the content type.

By design, Windows SharePoint Services fires events for all items in a list when the request is not bound to a content type to allow firing an event for all items when the event receiver is registered for all items in the list.

This behavior affects policies that involve Delete events. If you implement a policy that involves deletion, apply the policy to a content type, and then bind the content type to a list, the policy will apply to all items in the list, not only to the items of the content type to which the policy is applied.

Lists and content types

You register ItemUpdating and ItemUpdated events on a content type that is bound to a list, but the events fire even when items that are not of that content type are updated through the object model.

Windows SharePoint Services returns 0 (zero) as the content type ID, not the content type ID of the item.

Lists

The BeforeProperties property applies only to DocumentLibrary type lists.

The workaround is to return the properties by using the object model and the given list item ID.

Document libraries

You add a custom content type to a document library. ItemAdding, ItemAdded, and ItemUpdating events fire, but not ItemUpdated events.

This behavior occurs only for the Shared Documents document library and not for custom document libraries. For Shared Documents, adding a content type creates a Forms/<Content Type> folder and copies a Template.doc file into that folder, which causes the events to fire.

Document libraries and content types

For folders, you get the content type and content type ID through the AfterProperties property in the ItemAdding and ItemAdded, events, but for documents, you get the content type ID only in the ItemAdded event and nothing in the ItemAdding event.

The Windows SharePoint Services parser for Microsoft Office system documents does not set the content type name in a document dictionary. Document metadata does not set a content type name.

Lists

List events do not fire on the UserInfo list.

Lists

An ItemAdded event fires on a folder type item, but the list item ID is not returned.

Document libraries

Events do not fire when unlinking a document copy from the original document.

Document libraries

List item IDs always equal 0 when events fire on documents in the Forms folder. If you register an ItemUpdating event in a document library and then modify EditForm.aspx, the event fires, but the ID equals 0 (zero) because the item is not a regular list item.

Lists

Event receivers do not bind to a list when the list is provisioned through Onet.xml and the list type has an associated Feature that binds a receiver to the list. You create a Feature that binds a receiver to a list type, create a list of that type through the site definition, but the receiver is not bound to the list when a site is provisioned. A workaround is to bind the receiver to a content type instead, and then bind the content type to the list.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
List Item Events Pointers      Eugene Rosenfeld - MOSS MVP ... Jeroen Ritmeijer   |   Edit   |   Show History

Here are some other issues I ran into when working with event receivers:

  1. The ListItem attribute of the properties parameter is null on the ItemAdding event.
  2. The BeforeProperties and AfterProperties attributes of the properties parameter are not populated for the ItemDeleting event. Use the field values on the ListItem instead.
  3. We can't edit the ListItem properties directly when inside the ItemUpdating event. This causes an error message about conflicting updates. The exact error is: "Your changes conflict with those made concurrently by another user." Instead, set the AfterProperties collection with the new desired values. This is documented on Ishai Sagi's blog at:
    http://www.sharepoint-tips.com/2006/11/synchronous-list-event-handlers-ruin.html
  4. When creating folder the ItemAdded and ItemAdding events fire, but there is NO information available about the folder, not even its path or name. This makes it impossible to do any kind of useful validation.
Tags What's this?: Add a tag
Flag as ContentBug
How can i handle events for "User Information" list?      Saurabh Kumar Singh ... Thomas Lee   |   Edit   |   Show History

Hi,

I am just associating a custom Event handler feature with SharePoint "User Information" list, for creating a copy of newly added user in another sharepoint custom list with the help of "ItemAdded" event handler, which will maintain user profile but it doesn't seems to fire ItemAdding event with "User Information" list. I have read this article.
Can you please suggest me that how can i handle events for "User Information" list?

Thank you,
Saurabh Kumar Singh

[tfl - 18 05 09] Hi - and thanks for your post. You should post questions like this to the MSDN Forums at http://forums.microsoft.com/msdn or the MSDN Newsgroups at http://www.microsoft.com/communities/newsgroups/en-us/. You are much more likely get a quicker response using the forums than through the Community Content. For specific help about:
Visual Studio  : http://groups.google.com/groups/dir?sel=usenet%3Dmicrosoft.public.vstudio%2C&
.NET Framework : http://groups.google.com/groups/dir?sel=usenet%3Dmicrosoft.public.dotnet.framework
All Public     : http://groups.google.com/groups/dir?sel=usenet%3Dmicrosoft.public%2C&
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker