Copy Attachments without invoking ItemUpdated event - sharepoint

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.

Related

ItemUpdating event on DocumentSet

[;]
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.

How to catch item changes on list?

I have created state workflow in Sharepoint.
My idea is:
1/ when workflow is started create copy of list item on which workflow was started, this copy is created to another web list within current site collection - that's working
2/ monitor changes on parent item and propagate them to copied item - that's working
3/ monitor changes on copied item and propagate them back to original item - that's not working
I was trying to use IListItemService, but apparently it canno watch for changes on different then current web ? Is there any other way how to do it ?
I was thinking about SharePoint 2010 Pluggable Workflow Services - but in my class which derives from SPWorkflowExternalDataExchangeService method CallEventHandler was called twice even when only one call of SPWorkflowExternalDataExchangeService.RaiseEvent was made (this was called from custom event receiver) - another problem with this solution is when I recycle app pool I lost my singleton class which is responsible for maintaining list of state information needed for RaiseEvent method.
There is an event mechanism built into SharePoint just for this purpose. There's no need to use workflows or copy items.
Example: Creating a List Item Event Handler

SharePoint: Multiple events for single item updated

I have an item event receiver for a specific content type that is used in a Pages library. I am using the event logger to debug it, and I can tell that whenever I edit a page and publish it, it fires 3 ItemUpdating and 3 ItemUpdated events. I am certain that no other pages are being saved in that specific time.
What is the cause of this and is there any way to "fix" it to trigger only 1 event per page publish?
Alternatively, is there any way to distinguish the last of the events (ie: page is now published or being published) from the others, so I don't end up running my code three times?
As it turns out, it was because the page was actually being saved 3 times when a user clicks "Publish":
The document is saved.
The document is checked in.
The document is published.
Each of these triggers an ItemUpdated and ItemUpdating event.
Use the DisableEventFiring() method to prevent any other events from firing. Just remember to enable it again via EnableEventFiring(). Hope this helps.

When does Sharepoint List ItemDeleting event actually fire?

We would like to block the deletion of documents in a list based on some custom functionality.
What we have tried is to implement this in the ItemDeleting event. Where we set the cancel property of SPItemEventProperties to true when we do not want the user to be able to delete a document.
What happened was that the Delete option in the dropdown menu disapeared when the user was not allowed to delete a document. In a way this works, but the event is firing before the user actually tries to delete the document.
What is giving us problems is that the user can delete a document if they connect to the document library via MS Word 2003. In that case it does not appear that the ItemDeleting event fires.
Is there a way that we can get an event to fire and rollback the deletion when the document is deleted via MS Word.
Edit
Part of the problem could be that events do not fire in explorer view. Is there a fix for this "bug"?
ItemDeleting - An event that fires before an item is deleted.
more click here
I do not have sharepoint development environment right now so I can not give the exact answer but you can check on one thing that when user performs any action on a document from MS Word 2003 ItemUpdating event is fired. You can explore ItemUpdating event to see what is going to happen with the document and then deal with it accordingly.

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.

Resources