When someone is hired at my school, our HR system sends tech support an automated message with some basic information (first name, last name, start date, personal email address, job title, supervisor, etc.). Unfortunately, this isn’t formatted the best and I used to copy/paste the information from this email into an onboarding Google Sheet I used to mange the process.
I decided to try to improve on this process. I wanted the email to automatically go into my Google Sheet. While I’d love it if our payroll system could pass along the data I need in JSON format via a webhook/API call, alas it can’t do that. I figured that I could write some App Script to parse the emails and grab the data that way. However, before coding, I always like to check if someone has already solved the problem. CloudHQ has an add-on called “Export Email to Sheets” which does exactly what its name suggests. For any email with a given Gmail label (I match on sender and subject) it parses the email and adds the results to a Google Sheet.
As I covered in a previous blog post, I like writing GAM-ADV-XTD3 commands a Google Sheet formulas. I can create an account and send the password to the users personal email with the following Google Sheet formula:
="gam create user " & (left(I2,find("@",I2)-1)) & " firstname """ & A2 & """ lastname """ & B2 & """ password random changepassword on notify " & E2
Here is a key to the fields I’m using:
|A field with the new school email address we are creating|
|Calculates into the part of their email address before the @ symbol|
|A field with the first name of the new hire|
|A field with their last name of the new hire|
|The personal email address of the new hire|
To create an account for me:
gam create user ssimon firstname "Shandor" lastname "Simon" password random changepassword on notify firstname.lastname@example.org
Once the account is created there are a few other useful GAM commands:
Put the new user in an OU
gam update user ssimon org "/Faculty and Staff"
Add the user to a group
gam update group email@example.com add member user ssimon