SharePoint | Conditionally Aprove List Item When Content Aproval is Enabled

We can programatically aprove an item with
item.Aprove("my comment");

the thing is, this will end up in an exception when Content Aproval is not enabled for a list (cheking in is enough to make the item available).

I tried using item.ModerationInformation.Status but it turns out this attribute isn't even available for lists without content aproval.

so I end up with this:


if (myfile.Item.ModerationInformation != null)
{
myfile.Approve("");
}

Comments

Popular posts from this blog

Breaking down document locking in SharePoint

Working around X-Frame-Options for iframes

Document ID not being generated