title: Programatically enable Content Approval (Moderation) in SharePoint List
body: <p>I am writing a app that creates a custom events list.</p>
  
  <p>I'd like to enable content approval (also referred to Moderation on the back end) upon creation of the list.</p>
  
  <p>Here's what my list-creation code looks like.</p>
  
  <pre><code>    function createList(listToCreate)
  {
      // Create a SharePoint list with the name that the user specifies.
      var hostUrl = decodeURIComponent(getQueryStringParameter("SPHostUrl"));
      var hostContext = new SP.AppContextSite(currentContext, hostUrl);
      var hostweb = hostContext.get_web();
      var listCreationInfo = new SP.ListCreationInformation();
  
      //title the list
      listCreationInfo.set_title(listToCreate);
  
      //set the base type of the list
      listCreationInfo.set_templateType(SP.ListTemplateType.events);
  
      var lists = hostweb.get_lists();
      //use the creation info to create the list
      var newList = lists.add(listCreationInfo);
  
      var fieldCollection = newList.get_fields();
  
      //add extra fields (columns) to the list &amp; any other info needed.
      fieldCollection.addFieldAsXml('&lt;Field Type="User" DisplayName="Requester" Name="Requester" /&gt;', true, SP.AddFieldOptions.AddToDefaultContentType);
      fieldCollection.addFieldAsXml('&lt;Field Type="User" DisplayName="Manager" Name="Manager" /&gt;', true, SP.AddFieldOptions.AddToDefaultContentType);
      fieldCollection.addFieldAsXml('&lt;Field Type="Boolean" DisplayName="Approved" Name="Approved" /&gt;', true, SP.AddFieldOptions.AddToDefaultContentType);
  
      //Attempting to enable moderation. This doesn't seem to have any effect.
      newList.set_enableModeration(true);
  
      currentContext.load(fieldCollection);
      currentContext.load(newList);
      currentContext.executeQueryAsync(onListCreationSuccess, onListCreationFail);     
  }
  
  function onListCreationSuccess() {
      alert("We've created a list since one didn't exist yet. Look in the site that hosts this app for the list." );
  }
  
  function onListCreationFail(sender, args) {
      //alert("We didn't create the list. Here's why: " + args.get_message());
  }
  </code></pre>
  
  <p>Unfortunately it seems that <code>.set_enableModeration(true);</code> has no effect. I don't get any errors, but when I look at the settings for the list I created using this code I see this:
  <img src="https://i.stack.imgur.com/OajHH.png" alt="enter image description here"></p>
  
  <p>So Content Approval clearly was not enabled via the method I'm using.</p>