kamagra how much to take

Setting SPListItem Moderation Status In C#

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.

  1. private static void moderationPendingFix(SPListItem curItem)
  2. {
  3. if (curItem.ParentList.EnableModeration == true)
  4. {
  5. try
  6. {
  7. SPModerationInformation moderationInformation = curItem.ModerationInformation;
  8. if (moderationInformation.Status != SPModerationStatusType.Pending)
  9. {
  10. moderationInformation.Status = SPModerationStatusType.Pending;
  11. curItem.Update();
  12. }
  13. }
  14. catch (Exception exception)
  15. {
  16. //TODO: Exception Handling
  17. }
  18. }
  19. }

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!


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>