Apps Script - Google Forms

68 views
Skip to first unread message

Sarah Peacock [She-Her]

unread,
Oct 8, 2024, 9:41:10 AM10/8/24
to Google Apps Script Community
Hi Group,

I occasionally use a little bit of Apps script in my work. I am in no way an expert - definitely a beginner coder and I copy and edit a lot of script.

I've used this script in a Google Form to close when a limit of 10 submissions is reached.
I'd also like it to trigger an email to 3 email addresses when this happens so they can get the data, do stuff and then reset the form for the next month. How do i go about adding the code to notify when the limit is reached?

The trigger is set to Form Submit

Thanks in advance!

//

function CloseFormWhenFull() {
   
    let  maximum = 10;
    let  form = FormApp.getActiveForm();
    let  responses = form.getResponses();
  let count = responses.length;
  //Logger.log(count);
  if (count === maximum){

    form.setAcceptingResponses(false);

  }

}

//

Bennett, Scott

unread,
Oct 8, 2024, 9:51:29 AM10/8/24
to google-apps-sc...@googlegroups.com
function CloseFormWhenFull() {
   
    let  maximum = 10;
    let  form = FormApp.getActiveForm();
    let  responses = form.getResponses();
  let count = responses.length;
  //Logger.log(count);
  if (count === maximum){
GmailApp.sendEmail('email1,email2,email3','subject','body')
    form.setAcceptingResponses(false);

  }

}

You will have to run it manually from the editor once to add the new permissions since a new service was added. 

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/d51357ce-c1fe-486d-af81-1b2905a25318n%40googlegroups.com.


--
Scott Bennett


Sarah Peacock [She-Her]

unread,
Oct 11, 2024, 3:51:30 AM10/11/24
to Google Apps Script Community
Thanks Scott. Much appreciated.
Reply all
Reply to author
Forward
0 new messages