I ran into something simple today when I was writing a new event receiver for my current gig at Shaw AFB. The event handler itself was very simplistic. All it does is reference a piece of metadata within the SPListItem being uploaded into a document library, and based on that piece of metadata, route the document to possibly other locations, in this case a different instance. Besides the obvious limitation of the SPFile.MoveTo() function not being able to go cross-sites (which, honestly, I really despise since the method name is misleading IMHO), I had to set the the moderation status of the SPListItem being consumed within a seperate method via passing it in by a parameter to pending. Well, I take that back, I set the moderation status of the item if moderation status for the item is enabled, and if the SPModerationStatusType is not already pending :-) The code itself, is very, very simple, and when doing document moves, it adds a little touch of elegancy to your programming if you are doing such transitions within your development!
The SPModerationType enumeration has 5 members:
You see in the below method that I am using the Pending member.
private static void moderationPendingFix(SPListItem curItem)
if (curItem.ParentList.EnableModeration == true)
SPModerationInformation moderationInformation = curItem.ModerationInformation;
if (moderationInformation.Status != SPModerationStatusType.Pending)
moderationInformation.Status = SPModerationStatusType.Pending;
catch (Exception exception)
//TODO: Exception Handling
As you can see, minus the fact I leave the exception handling to the reader, it is very easy to achieve this particular piece of functionality, and when moving documents, is very helpful!