2

I'm updating item in SPListItemCollection using SPListItem.Upadte() but my event receiver is not receiving ItemUpdating/ItemUpdated events (breakpoints are not hit on either handlers).

Sample code that fails to invoke itemupdating event:

SPListItem opFolder = list.Folders.Add(strURL, SPFileSystemObjectType.Folder, strNewName);

opFolder["ContentTypeId"] = strNewContentType;
opFolder["ParentID"] = spf["NodeID"].ToString();
opFolder.Update();
  • And you are sure you are not calling DisableEventFiring() before SPListItem.Upadte()? – Diptarag Nov 22 '12 at 13:55
  • How did you register the event receiver? – James Love Nov 22 '12 at 19:03
  • @JamesLove I've run it from VS2010. Receiver is working since i'm receiving ItemAdding from that same piece of code (im calling SPList.Folders.Add which fires itemadding before calling update on splistitem). Also itemupdating is fired when i add new item from SP DocLibrary itself. – Nemanja Nov 23 '12 at 8:48
  • @Diptarag Nope, there is no DisableEventFiring call in the receiver or in webpart. – Nemanja Nov 23 '12 at 8:49
  • 1
    try to start the debugger with a Debugger.Break or similar in the event handler code, so we can exclude that the problem is caused your debugger begin attached to the wrong process (since I have seen that behaviour in visual studio in the past). – SPArchaeologist-様 Nov 23 '12 at 14:37
1

Are you running this code with Elevated Priveleges?

If so it sends a SystemUpdate() which does not fire events.

  • I've been playing around this issue, and i've found that if i execute Update AND SystemUpdate in succsession, ItemUpdating event is fired? – Nemanja Nov 28 '12 at 13:48
  • 4
    MSDN: "When you call the SystemUpdate() method, events are triggered and the modifications are reported in the Change and Audit logs, but alerts are not sent and properties are not demoted into documents." I checked in SP2013 - it DOES fire the events! – dbardakov Aug 13 '14 at 11:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.