Ugh! I've just realised our production lists are using content deployment,
which has the unfortunate side effect of putting items into a Pending state
when I update them. :\

For anyone who's yet to go through this pain, you cannot perform an Update
and Moderate method within the same batch command. Or at least I was unable
to. Splitting them out didn't help either.

I wound up having to do this via OM using the following code. Hopefully it
will save someone else some time.

Time to publish that blog post. :)

curItem = SPContext.Current.ListItem;

if (theList.EnableModeration == true)
{
        // Get Content Approval status
        SPModerationInformation moderationInformation =
curItem.ModerationInformation;

        // Approved
        if (moderationInformation.Status == SPModerationStatusType.Approved)
        {
            // Update item
            curItem["Counter"] = newCount;
            // Approve item
            moderationInformation.Status = SPModerationStatusType.Approved;
            curItem.Update();
        }
        // Pending
        else if (moderationInformation.Status ==
SPModerationStatusType.Pending)
        {
         // Don't count Pending items
     }
 }
 // No content approval
 else
 {
     // Update item
    curItem["Counter"] = newCount;
    curItem.Update();
}
_______________________________________________
ozmoss mailing list
[email protected]
http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss

Reply via email to