I have 2 Google forms set up for school referrals.When a teacher submits a referral form, it's auto-transferred to a Google sheet, where an automatic link is generated. This link is to a form that only administration fills out. The link transfers all the information from the first form into the second form, as the second form has all the same questions as the first, but with an extra section for administrative decision.
When an administrator fills out this second form, I have coded the following into the actual 2nd (Administration only) form:
function onFormSubmit() {var form = FormApp.getActiveForm();var formResponses = form.getResponses();for (var i = 0; i < 1;i++) { var formResponse = formResponses[i]; var itemResponses = formResponse.getItemResponses(); for (var j = 0; j < 1;j++) { var itemResponse = itemResponses[j];email = itemResponses[1].getResponse();personName = itemResponses[3].getResponse();adminAction = itemResponses[11].getResponse();adminCode = itemResponses[12].getResponse();adminComment = itemResponses[13].getResponse();studentName = itemResponses[0].getResponse();GmailApp.sendEmail(email,"Referral Results", "Hello " + personName +",\n\n" +"Please see below for the administrative response in regards to your referral:\n\n\t" +"Student Name:\t" + studentName +"\n\t" +"Disciplinary Action:\t" + adminAction +"\n\t" +"Aspen Code:\t" + adminCode +"\n\t" +"Comments by Administration:\t" + adminComment +"\n\nThank you.\nThis is an automated message."); }}}This code is to generate an automated message. This code is supposed to send an email from my account and notify teachers via the email they submitted when administration has made a decision on their referral. However, this code has been sending emails to the same teacher who submitted a referral first (Listed as 1 in the form) for every administrator filling out and submitting the 2nd form. The referral emails are not being sent to the teacher who submitted a referral, instead it just sends the first referral to the first email over and over.
I want the code to send out referral results to the email from the result that's been submitted, not just the email from the first response. I don't want to keep flooding the 1st teachers email.









