Environment: SP2010 Enterprise, VS2012, c#, full server access
Simple question...
I'm using a console app to create sub-folders in a document library based on user input, then calling SPListItem.SystemUpdate(false) to keep from triggering alerts. But the alerts are firing anyways, as if it were a regular Update()
Can anyone spot my problem? I'm guessing it has to do with SPItemEventReceiver.ItemAdding method, but I don't know what or how to change that.
Here's the code:
SPList oList = oWeb.Lists[listName];
SPFolderCollection oCol = oList.RootFolder.SubFolders;
SPFolder oFolder = oCol[folderName];
SPListItem newFolder = oList.AddItem(oFolder.Url, SPFileSystemObjectType.Folder, newFolderName);
newFolder.SystemUpdate(false);
Update: Further research on the event receiver involved led me to this page... http://sharepointdevelopertopics.blogspot.com/2011/04/changes-disabling-event-firing-in.html ...which sounds like exactly what I need. BUT it made no difference when I implemented it. The alerts were still triggered. Is that something that simply cannot be done for folder creation? SystemUpdate works fine for changing item properties, but not folders, which is leading me to believe it just can't be done.
Going to keep testing...
Further Updates: Using elevated privileges did not do the trick, nor did updating the SPList as well as the SPListItem. What's really bizzare in my opinion is that even switching the EventFiringEnabled() off and then running the update (as per the link above) doesn't have any effect, alerts still fire normally. I've tried wrapping every piece in SPSecurity/Using SPSite/Using SPWeb, and even specified the list in the event handler class just in case the application had any doubts about my rights or where this was supposed to take place... Still nothing. It seems to be completely ignoring my command to turn off EventFiringEnabled.
Where I am now was: Basically it has come down to the EventFiringEnabled not actually switching off when I tell it to. Is there a good way to troubleshoot this? Or should I just rewrite the whole built-in event handler?
Now where I am: Further update, at some point during all my testing I apparently switched off the event receiver in question, because today NO alerts are firing. I'm revising my code to flip it back on (found the flaw that I think is responsible for leaving it disabled) and going to continue battery testing until I find an answer, but the fact that it actually disabled at SOME point is encouraging. Is there perhaps a timeframe that has to pass or a service that needs to run to make the EventFiringEnabled(false) take effect? Or should it just be immediate? Turns out this was caused by a solution from CodePlex I was testing, "SharePoint Column & View Permission". It (unintentionally) disabled all alerts on the site after I installed it. Uninstalling the wsp set alerts back to normal.