Clear thinking · Useful delivery · Work built to last

PEN BEAM / COPY-READY EXAMPLE

Google Apps Script — Send a Form Notification

JavaScript (Apps Script)AutomationGoogle Apps Script; spreadsheet-bound form-submit trigger

Notify a team when a form response arrives without copying sensitive answers into the email.

What this snippet does

Sends a brief notification when a form response is received. The email confirms that a response arrived without reproducing form answers or other potentially sensitive fields.

JavaScript (Apps Script) / source code
/**
 * Attach to a spreadsheet-bound "On form submit" trigger.
 * Notification text deliberately excludes submitted answers.
 */
function notifyTeamOfFormSubmission(e) {
  if (!e || !e.range) {
    throw new Error('This function expects a spreadsheet form-submit event.');
  }
  const recipient = 'REPLACE_WITH_RECIPIENT@example.com';
  if (!recipient || recipient.indexOf('REPLACE_') === 0) {
    throw new Error('Set a real notification recipient before enabling the trigger.');
  }
  const sheetName = e.range.getSheet().getName();
  const responseRow = e.range.getRow();
  const submittedAt = new Date().toISOString();
  MailApp.sendEmail({
    to: recipient,
    subject: 'A new form response was received',
    body: [
      'A new form response has been recorded.',
      'Response sheet: ' + sheetName,
      'Response row: ' + responseRow,
      'Notification time: ' + submittedAt,
      '',
      'Open the response spreadsheet using your authorized account to review details.'
    ].join('n')
  });
}

Where to place it

Open the response spreadsheet, choose Extensions → Apps Script, paste the function and create an installable spreadsheet “On form submit” trigger. Authorize the mail scope when prompted.

Back up the relevant file or settings first. Apply the change on staging, verify behavior, and retain a rollback path before production deployment.

What to check before deploying

  • Authorize the script and install the spreadsheet On form submit trigger.
  • Replace the recipient placeholder and verify it is monitored; do not include sensitive form answers in the email.
  • Submit a test response, confirm the message arrives, inspect Apps Script Executions for errors and review quotas before relying on it.

Related snippets

Need this adapted to your project? Start a project