Export (0) Print
Expand All

Event Troubleshooting

Last modified: April 09, 2010

Applies to: SharePoint Foundation 2010

In this article
Document Libraries and Content Types
Lists and Content Types
Document Libraries
Webs

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

The event behaviors are divided into four categories:

  • Document Libraries and Content Types

  • Lists and Content Types

  • Document Libraries

  • Webs

ISSUE

DESCRIPTION

ISSUE #1

An .aspx page of a specific content type is created in a document library. The page is associated with ItemAdding and ItemAdded events. However, these events are not raised.

Resolution: When a file is uploaded to a document library, it is assigned a default content type. However, if you upload a file and then assign it a content type, for example, content type "A", the result is that you are changing the content type of the file from the default to content type "A" after it has been added to the document library.

In this scenario, when content type "A" has event bindings to ItemAdding/ItemAdded and ItemUpdating/ItemUpdated, the ItemAdding/ItemAdded events are not raised when you assign the new content type "A" to the file. However, the ItemUpdating/ItemUpdated events are raised in this scenario.

In cases where the file is created directly from the content type by using the New Document feature instead of uploading the document, then the ItemAdding/ItemAdded events are raised successfully, as well as the ItemUpdating event.

ISSUE #2

An ItemAdding event that is bound to a content type is raised even when a document that is not of that content type is uploaded. Note that every document that is uploaded to a document library is first assigned to the default content type. Therefore, any time you add a document to a document library, the ItemAdding\ItemAdded events are raised if those events are bound to the default content type.

Resolution: The content type of the document can be changed during the Update phase and the content type identifier (ID) is adjusted accordingly.

ISSUE #3

A request to delete an item through a list form does not provide an associated content type ID. Therefore, the ItemDeleting and ItemDeleted events are raised on all list items, not only on items of a specific content type. This occurs even if the event was registered only for the specified content type.

Resolution: By design, SharePoint Foundation raises events for all list items when the request is not bound to a content type. This allows an event to be raised 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.

ISSUE

DESCRIPTION

ISSUE #1

When you register the ItemUpdating event on a content type that is bound to a list, the event occurs even when items that are not of that content type are updated through the object model. Note that SharePoint Foundation returns 0 (zero) as the content type ID, and not the content type ID of the item.

Resolution: None.

ISSUE #2

List events are not raised on the UserInformation list type.

Resolution: None.

ISSUE

DESCRIPTION

ISSUE #1

When adding a new content type to a list that has events that are bound to it, some of these events might be raised because binding a content type to a list can involve intervening factors, such as sometimes adding files (like Template.doc), updating documents, or adding new fields.

Resolution: 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 occur.

ISSUE #2

When adding a document to a document library in Explorer view by using WebDAV, the ItemAdding(SPItemEventProperties) and ItemAdded(SPItemEventProperties) methods are called one time, but the ItemUpdating(SPItemEventProperties) and ItemUpdated(SPItemEventProperties) methods are called twice.

Resolution: None. This behavior is by design, as internal processes involved in adding a file in Explorer folder view necessitates calling these methods twice.

ISSUE #3

When you rename a file in a document library by using WebDAV in Explorer view, the renaming event does not raise the ItemUpdating(SPItemEventProperties) and ItemUpdated(SPItemEventProperties) events, unless you also change the file extension when renaming the file.

Resolution: None.

ISSUE

DESCRIPTION

ISSUE #1

For the WebAdding(SPWebEventProperties) and WebProvisioned(SPWebEventProperties) methods, the ServerRelativeUrl property is empty when the parent Web is the root Web.

Resolution: The correct values for the ServerRelativeUrl property on a WebAdding event is the URL of the parent Web. The correct value on a WebProvisioned event is the URL of the newly created subweb.

ISSUE #2

Setting the event receiver status to CancelNoError in a WebDeleting(SPWebEventProperties) or SiteDeleting(SPWebEventProperties) event causes a redirection to an error page that indicates that the Web has been deleted.

Resolution: None. The control is simply returning the caller after the event has been raised. The Web has not been deleted.

ISSUE #3

Setting the event receiver status to CancelNoError in a FieldAdding(SPWebEventProperties) event causes a redirection to an error page that indicates that the column does not exist when you are adding a field to a list.

Resolution: None. The control is simply returning the caller after the event has been raised. The column has not been deleted.

ISSUE #4

Setting the event receiver status to CancelNoError in an ItemAttachmentDeleting(SPWebEventProperties) event causes a redirection to an error page that reads "Exception from HRESULT" error when you try to remove an attachment from an item.

Resolution: None. The control is simply returning the caller after the event has been raised.

Show:
© 2014 Microsoft