title: Automation Of Adding New Group Member in Google Apps--Using Google Script
body: <p>I am trying to accomplish what I imagine would be a fairly simple automation in Google Apps, but I am new to Google Scripts and am having trouble figuring out how the triggers to execute the script work.</p>
  
  <p><strong>Here is some pseudo code describing what I think I need to do:</strong></p>
  
  <pre><code>//When a new group is created execute the function below
  
  function addNewSalesTeamGroupMember() {
    //Get the new group's id/email address
    //Add it as a new member of the Sales Team group (id=SalesTeam@mydomain.com)
  }
  </code></pre>
  
  <p><strong>Here is some background on the task at hand:</strong></p>
  
  <p>I have a Google Apps account that is using Groups as email forwarders. For example, there are 50 groups each with 1 member that serve to provide an email account on the domain for sales team members (e.g. salesguy@mydomain.com is a group whose only purpose is to forward to Sales Guy's third-party email address: salesguy@yahoo.com). There is also another group, SalesTeam@mydomain.com, that contains each of the sales team members, so a manager could make announcements to the whole Sales Team at once.</p>
  
  <p>My task is to write a script that will automatically add any new sales members that are created to the SalesTeam group, as they are created. It thus needs to run when a new sales member is added (i.e. when a new group is made). </p>
  
  <p>I've got the <a href="https://developers.google.com/google-apps/provisioning/#updating_a_group" rel="nofollow">API for updating Groups</a>, but I can't find any resources describing how to write the trigger to tell the script to execute when a new group is created, and to thus be able to retrive the new group's address. In other words, I'm looking to learn how to write this part of my pseudo code in Google Scripts:</p>
  
  <pre><code>//When a new group is created execute the function below
  </code></pre>