11

The SharePoint Object Model provides a property of an SPListItem called SPListItem.ModerationInformation.Status to allow you to determine the current content approval / moderation status if a document library has content approval enabled. The property ModerationInformation is an instance of the class SPModerationInformation and Status is an instance of the enum SPModerationStatusType.

How can I work with these objects / properties from the Client Side Object Model? The client side ListItem does not contain the ModerationInformation property like its server-side counter part.

11

Even though the CSOM ListItem class does not have a ModerationInformation property, I was able to access this value through the field's internal name:

ListItem item = file.Item;
clientContext.Load(item);
clientContext.ExecuteQuery();

int status = Convert.ToInt32(item["_ModerationStatus"]);

And the enum is defined as:

public enum SPModerationStatusType
{
    Approved, //0
    Denied,   //1
    Pending,  //2
    Draft,    //3
    Scheduled //4
 }

This got me where I needed to be.

  • 2
    As a side note when using REST use item["OData__ModerationStatus"] instead of item["_ModerationStatus"] – nbi Jun 6 '16 at 6:55
1
    Here is the full list of Internal Column name :

    https://sharepointmalarkey.wordpress.com/2008/08/21/sharepoint-internal-field-names/

public enum Status
{
    Approved, //0
    Denied,   //1
    Pending,  //2
    Draft,    //3
    Scheduled //4
 }

    ListItem item = ctx.Web.Lists.GetByTitle('listname').AddItem(listObj);
    clientContext.Load(item);
    clientContext.ExecuteQuery();
    item["_ModerationStatus"] =  Convert.ToInt32(Status.Approved);
    item.Update();
    ctx.ExecuteQuery();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.