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.
Here is some pseudo code describing what I think I need to do:
//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)
}
Here is some background on the task at hand:
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.
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).
I've got the API for updating Groups, 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:
//When a new group is created execute the function below