appscript.dev
Automation Intermediate Forms Gmail Drive Sheets

Trigger an onboarding sequence on form submit

Kick off tasks when a new Northwind hire submits their starter form.

Published Oct 17, 2025

The first day of a new Northwind hire is also the day three or four people remember they were supposed to set something up. A Drive folder, a row on the onboarding tracker, a welcome email — all small jobs, all easily forgotten. Doing them by hand for every joiner is fine while you hire twice a year, then quickly becomes a mess once hiring picks up.

This script turns one form submission into the whole opening sequence. The new hire fills in their starter form; on submit, the script provisions their personal folder, adds them to the onboarding queue, and sends a welcome email with their first link. The people coordinator only steps in when something needs a human.

What you’ll need

  • A Google Form with three questions titled exactly Name, Email, and Role — these become the keys in e.namedValues.
  • A Drive folder where each hire’s folder will live, with the script owner as an editor. Save its ID in HIRES_PARENT_FOLDER.
  • A Google Sheet acting as the onboarding tracker, with a header row matching the columns the script appends. Save its ID in ONBOARDING_SHEET.
  • A form-submit trigger pointing at onFormSubmit.

The script

// Drive folder where each new hire gets a sub-folder.
const HIRES_PARENT_FOLDER = '1abcHiresFolderId';

// Sheet that tracks the onboarding queue. Columns: date, name, email, role,
// folder, status.
const ONBOARDING_SHEET = '1abcOnboardingId';

// Who signs the welcome email.
const SIGNATURE = '— Awadesh';

// Starting status for every new row.
const INITIAL_STATUS = 'pending';

/**
 * Form-submit handler. Spins up a folder, queues the hire, and welcomes them.
 *
 * @param {GoogleAppsScript.Events.FormsOnFormSubmit} e
 */
function onFormSubmit(e) {
  // 1. Pull the answers out of the event. Each value is an array because
  //    Forms supports multi-select; for these single-answer questions we
  //    want the first entry.
  const name = e.namedValues.Name?.[0];
  const email = e.namedValues.Email?.[0];
  const role = e.namedValues.Role?.[0];

  // 2. Bail out cleanly if any required field is missing — better a clear log
  //    line than a half-provisioned hire.
  if (!name || !email || !role) {
    Logger.log(`Skipping submission with missing fields: ${JSON.stringify(e.namedValues)}`);
    return;
  }

  // 3. Create the hire's personal folder under the shared parent and give
  //    them editor access on it.
  const folder = DriveApp.getFolderById(HIRES_PARENT_FOLDER).createFolder(name);
  folder.addEditor(email);

  // 4. Append a row to the onboarding tracker. The status column starts as
  //    "pending" so the coordinator can see at a glance what is open.
  SpreadsheetApp.openById(ONBOARDING_SHEET)
    .getSheets()[0]
    .appendRow([new Date(), name, email, role, folder.getUrl(), INITIAL_STATUS]);

  // 5. Welcome email. Plain text — the link to their folder is the only
  //    interactive bit so it does not need to be HTML.
  const subject = 'Welcome to Northwind';
  const body =
    `Hi ${name},\n\n` +
    `Welcome aboard. Here is your starter folder — it is yours, share what you like:\n` +
    `${folder.getUrl()}\n\n` +
    `You are joining as ${role}. We will see you on Monday.\n\n` +
    SIGNATURE;
  GmailApp.sendEmail(email, subject, body);

  Logger.log(`Onboarded ${name} <${email}> as ${role}.`);
}

How it works

  1. The form-submit trigger fires onFormSubmit with an event object whose namedValues holds each answer keyed by question title.
  2. The script reads Name, Email, and Role, taking the first entry from each array. If any of the three is missing, it logs and returns — better than provisioning a half-broken record.
  3. It creates a sub-folder named after the hire inside the shared hires parent, then calls addEditor so the new joiner can drop documents into their own space from day one.
  4. It appends a row to the onboarding sheet with a timestamp, the hire’s details, the folder URL, and a starting status of pending. That row is the work item the people coordinator picks up next.
  5. It sends a plain-text welcome email with the folder link inline. Gmail auto-links the URL so the hire can click straight through.
  6. A single log line at the end gives the executions panel a clear “this hire was set up” record — useful when you are debugging which run did what.

Example run

A new hire submits the starter form with:

QuestionAnswer
NameMei Tanaka
Email[email protected]
RoleProduct designer

Within seconds:

  • A Drive folder named Mei Tanaka appears under the hires parent folder, with [email protected] added as editor.
  • A new row lands on the onboarding sheet:
DateNameEmailRoleFolderStatus
2025-10-17 09:12Mei Tanaka[email protected]Product designerhttps://drive.google.com/pending
  • Mei receives an email titled “Welcome to Northwind” with the folder link and a one-line note about Monday.

Trigger it

This needs an installable on-submit trigger — the simple onFormSubmit name is not enough when the script touches Drive, Sheets, and Gmail.

  1. In the Apps Script editor, open Triggers (clock icon, left sidebar).
  2. Click Add trigger and choose onFormSubmit.
  3. Event source: From form. Event type: On form submit.
  4. Save and approve the authorisation prompts.

Watch out for

  • Question titles are the contract. Rename Role to Job title in the form and the script silently skips every submission. Either freeze the titles or switch to e.values indexed by position.
  • Folder names collide. Two hires called Sam will both get a Sam folder unless you suffix the name with the role or a hire date. Drive allows duplicate folder names but humans hate it.
  • Email deliverability. The welcome email is sent as the script owner — if the owner is a personal account, expect occasional spam-folder delivery. Bind the script to a workspace user, or send via a Google Group alias.
  • Re-runs duplicate work. Trigger glitches occasionally fire twice for the same submission. Add an idempotency check — look up the email in the onboarding sheet before appending — if duplicate folders would actually hurt.

Related