Posts Tagged ‘approval status’


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.