Skip to content

Instantly share code, notes, and snippets.

@sanbornick
Last active March 6, 2017 23:20
Show Gist options
  • Save sanbornick/dd219684c4062c1ae0c427f980dd04ea to your computer and use it in GitHub Desktop.
Save sanbornick/dd219684c4062c1ae0c427f980dd04ea to your computer and use it in GitHub Desktop.
Notify manager upon submission in Google Forms
function onSubmit(e) {
var formResponse = e.response;
var respondant = formResponse.getRespondentEmail();
var user = AdminDirectory.Users.get(respondant);
var userManager, a;
for (a = 0; a < user.relations.length; a++) {
if (user.relations[a].type == 'manager') {
userManager = user.relations[a].value;
}
}
if (userManager) {
MailApp.sendEmail(
userManager,
user.name.fullName + ' submitted Google Form: ' + e.source.getTitle(),
user.name.fullName + " <" + user.primaryEmail + '> submitted Google Form ' + e.source.getTitle() + ' on ' + new Date().toString(), {
noReply: true
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment