Read or Update Content Approval Status Column or Moderation Column using SharePoint Client Side Object Model(CSOM)

Posted: March 1, 2013 in Code, CSOM
Tags: ,

Most often you don’t come across this requirement of updating the content approval status column. Below is the scenario I had.

I had a list containing video items.  This has the content approval functionality enabled. On approval this column gets updated to approved. Approved items are displayed in search results. Opening an item displays a media player which plays the video. At this point, I update a column named “Views” in the list, which holds the view count of that video using CSOM. Unfortunately once I update this column, my content approval status became Pending. This makes my search not to crawl the item thereafter.

When i try to update this column to “Approved” in my CSOM code using the content approval column name, SharePoint was  not able to find the column name. So I found 2 things out here..

  • The content approval status column can be accesses using its internal name “_ModerationStatus“.
  • The value which we can assign to it is not Text but Integer. Because the value is defined as an enum internally which is “SPModerationStatusType“.

Below is the code detail and the possible status values & their corresponding enum values.

this.oListItemUpdate = oList.getItemById(listID);

    var wrkFlwApproval = this.oListItem.get_item(‘_ModerationStatus’);
    if(wrkFlwApproval == 0)
        this.oListItemUpdate.set_item(‘_ModerationStatus’, 0 );    

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

Word of caution : The user updating this column should have approver rights on the list.

  1. Shekar Reddy says:

    how to know which user has approved the item

  2. […] References: Read or Update Content Approval Status Column or Moderation Column using SharePoint Client Side Obje… […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s