ItemUpdating event on DocumentSet - sharepoint

[;]
We have a document-set the event receiver is attached to the ContentType (for Document-Set), the idea is when a new site is created document-Set is created as part of provisioning and the event is attached to the it. We tried attaching event-receiver using (typical) PS script. We can see the event-receiver attached in the SP Manager as well as the (event receiver) count.
The problem is Event receiver (itemupdated) does not trigger when user adds/updates the document within the document-Set.
Eventreceiver triggers when we try to modify documentSet metadata/fields, and when we attach it directly to the list instead of documentSet. The documentSet wraps the class SPFolder so the add/edit document will not trigger the itemUpdated event? Is there any event for when document is added/updated from the documentSet? What am I missing here?
Any pointers will be great help.
regards,
[;]

You need to add event handlers for each content type that can be stored in the document set that you want to handle the events for. For example, if your document set, holds 'Document' content types, you need to add event handlers for the 'Document' content type.
You have attached an event handler to the document set, but not the documents within the document set.

Related

Copy Attachments without invoking ItemUpdated event

I found a way to copy the attachments of a list item from one to another, therefore I used this code:
Sharepoint Online: Copy attachment of list item to a new item using Client object model
Now I have a new problem: I have an ItemUpdating & ItemUpdated event receiver, which listen both to my list, where the attachments are copied to. I want to prevent them from firing before all the attachments are copied. Actually the events are called when I save the list file (as I have to save before I'm able to copy the attachments!), but this should be avoided. Is there a possibility to "pause" the event receivers for this item until the attachments are copied? I need to realize it with the client object model.
Is it one time requirement? If yes, then you can turn off event receiver Enable/Disable Event receiver on list for sometime (till you completely process the attachment uploads) and then re-enable it. As CSOM doesn't support event receiver customization you have to use the web services to do this job on client side.
If it is real time scenario where you need to run this based on some criteria then I don't think you can do it as CSOM doesn't support it.

What event is triggered when a document is saved in a Document Library in SharePoint?

We have a document list that contains Excel sheets, the documents that are in the list have to be processed. The processing code is triggered by the EventReceiver.
Until know we used the ItemCheckedIn event, but this isn't triggered when the user just saves a document from within Excel. I have tried to use the ItemUpdated event, but that doesn't seem to work either.
So I'm wondering whether there is an event that is triggered when a user saves the document from within Excel.
There are Before and After events when updating/adding list items. Here is a comprehensive list of all of those events:
Before Events
ItemAdding
ItemUpdating
ItemDeleting
After Events
ItemAdded
ItemUpdated
ItemDeleted
ItemAttachmentAdded
ItemAttachmentDeleted
ItemCheckedIn
ItemCheckedOut
ItemFileConverted
ItemFileMoved
ItemUncheckedOut
ItemAdded?
It's a little confusing since one event handler gets called when the document is initially saved and ItemUpdated gets called when you set any custom properties on the item, at least if you're using the default SharePoint web UI.

sharepoint event receiver events not firing

I added a workflow to my document library (with a custom content type) and now my content types event receiver function itemcheckingin doesnt fire. Double checked my xml files and it's being properly refered to and other events (itemupdating, itemadding) are firing. Any ideas?
Have you tried programmtically pulling down a list of Event Receivers using something like SPList.EventReceivers and seeing if the correct events are bound to your receiver? Sometimes the XML files don't show exactly what the database is holding.
-Shaun
Is your list item definitely of the content type that has the registered event handler? It sounds like you might have created a new item of the workflow-containing content type where that content type does not have a handler for the event of interest. I guess I interpret your post as saying that you now have two content types -- one with the workflow and one with the event handler.
I second #SCMcDonnell's suggestion to go straight to the horse's mouth and see what event receivers are registered for your list item and its content type.
EDIT: Oh, I guess I initially missed your claim that other events are firing successfully. That makes my answer less likely. Still, I recommend that you go specifically retrieve the event receivers for the offending list item.
Does the list have force checkout on it?
If it does, then the checkin fires and ItemUpdated as well. See this KB article
http://support.microsoft.com/default.aspx/kb/939307
if (properties.AfterProperties["vti_sourcecontrolcheckedoutby"] == null && properties.BeforeProperties["vti_sourcecontrolcheckedoutby"] != null)
{
//This is when the update event is triggered by check-in.
}
else
{
//This is triggered by events other than check-in action.
}

ItemUpdating not showing changed values in SharePoint event receiver

I'm trying to find how a field's value has changed in an ItemUpdating event receiver. The particular field's display name and internal name is Regions.
As soon as ItemUpdating is hit, the value of the Regions field is identical for the following:
properties.AfterProperties["Regions"]
properties.BeforeProperties["Regions"]
properties.ListItem["Regions"].ToString()
I would expect the latter two to contain the old value but surely AfterProperties should be set correctly.
Does anyone know how I can obtain the changed value?
Update: The event handler is attached to a MOSS 2007 publishing Pages list.
I've had a lot of trouble with event handlers on publishing pages libraries. Think it comes from their being other event handlers on there already for publishing. I had better success with updating, can you change to that or do you need the sync event to block the change ?
Are you trying this in a List or Document Library ?
It will work Only on the Doc Lib Please refer to these
MSDN and another on same subject

Capturing title change event on SPWeb

I am listening on a particular SPWeb using an SPWebEventReceiver that is successfully firing on the WebMoved event. When the web is moved I update a list with the new location/title.
What I would like to be able to do is listen for when the Web is renamed . Do I do this by attaching an item listener and waiting for an ItemUpdated event? If so I would appreciate a little snippet of code! Thanks!
It looks like this is a bug with the SharePoint OM. The event receiver is clearly supposed to fire when the name of a web is changed, but it does not. It only fires when the Web's URL is changed.
Steve,
As far as I can see, SPWebEventReceiver only exposes the following events on an SPWeb (http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spwebeventreceiver_members.aspx)
SiteDeleted
SiteDeleting
WebDeleted
WedDeleting
WebMoved
WebMoving
ItemAdded is defined in SPItemEventReceiver which is applicable to SPListItem objects.
The Title property of an SPWeb is stored in a property bag (http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.properties.aspx).
It doesn't appear like you can tap into any events when .Update() is called on the property bag, e.g. when Title is updated.
I would say that a rename of the Web name should trigger WebMoved.
Site title rename triggers no action.
Question: What changes do you want tot tap in? Because any metadata for instance could be stored in lists inside, which supports lots of events.
I don't believe it is a bug, I believe it is simply a misinterpretation of the documentation. As you have stated, the documentation indicates that the WebMoving and WebMoved events are triggered by the site's url being modified or being renamed:
from MSDN Doc: "Synchronous Before event that occurs before an existing Web site has been renamed or moved to a different parent object."
However, what gets changed in the UI is NOT the "name" of the site, but the site's title. The SPWeb object does have a "Name" property that is accessible through the Object Model, and updating that Name property and calling SPWeb.Update() does in fact trigger the WebMoved event. The trouble is that this property is not exposed through the web-based settings page for the site, only the "Title" field is exposed, and this field change does not trigger the event. While this seems a bit counter-intuitive and even misleading, if you read the documentation literally, it is behaving exactly as documented.

Resources