title: How to set Google Groups moderation and posting permissions
body: <p>I have got the below script working for me.... (Script auto creates a google group with data from a spreadsheet that is auto populated with data from a form...)</p>
  
  <pre><code>function onFormSubmit() {
   var sheet = SpreadsheetApp.openById("17KZXpWHipISZSqgD9w255VrirzITrks0fLaBpXp7Ybk")
   var email = sheet.getRange("B"+sheet.getLastRow()).getValue()
   var name = sheet.getRange("C"+sheet.getLastRow()).getValue()
   var user = sheet.getRange("AH"+sheet.getLastRow()).getValue()
   try{
     AdminDirectory.Groups.insert(
       {
         "email": email,
         "name": name,
       }
     )
     AdminDirectory.Members.insert(
       {
         "email": user,
         "role": "OWNER",
       }
       , email)
     GmailApp.sendEmail("Manager@test.co.uk",email + "  Group creation | Success", " address has been created for " + name)
   } catch(e){}
  }
  </code></pre>
  
  <p>Could someone help me finish it as the remaining steps that i cannot get working are:</p>
  
  <p>Set Group Moderation settings to: Skip Moderation queue and Post messages to group</p>
  
  <p>Set Posting permissions to: public</p>
  
  <pre><code>function onFormSubmit() {
   var sheet = SpreadsheetApp.openById("17KZXpWHipISZSqgD9w255VrirzITrks0fLaBpXp7Ybk")
   var email = sheet.getRange("B"+sheet.getLastRow()).getValue()
   var name = sheet.getRange("C"+sheet.getLastRow()).getValue()
   var user = sheet.getRange("AH"+sheet.getLastRow()).getValue()
   try{
     AdminDirectory.Groups.insert(
       {
         "email": email,
         "name": name,
       }
     )
     AdminDirectory.Members.insert(
       {
         "email": user,
         "role": "OWNER",
       }
      )
     AdminDirectory.Groups.update(
       {
         "whoCanJoin": "CAN_REQUEST_TO_JOIN",
         "whoCanViewMembership": "ALL_IN_DOMAIN_CAN_VIEW",
         "whoCanViewGroup": "ALL_IN_DOMAIN_CAN_VIEW",
         "whoCanInvite": "ALL_MANAGERS_CAN_INVITE",
         "allowExternalMembers": "false",
         "whoCanPostMessage": "PUBLIC",
       }
      )
     AdminDirectory.Groups.moderation(
       {
        "Spammessages": "Skip_the_moderation_queue_and_post_to_the_group"
       }
       , email)
     GmailApp.sendEmail("r.hershey@onemotion.co.uk",email + "  Group creation | Success", " address has been created for " + name)
   } catch(e){}
  }
  </code></pre>
  
  <p>I tried this but either I'm tired or I'm missing something silly...?</p>