A lightweight Google Apps Script automation for Google Workspace user lifecycle management.
This project helps HR, IT, and Workspace administrators create and suspend users from Google Forms submissions, automatically add users to Google Groups, send welcome emails, and create manager calendar reminders — using Google Sheets, Apps Script, and the Admin SDK Directory API.
┌──────────────┐ ┌──────────────────┐ ┌─────────────────────┐
│ Google Forms │────▶│ Google Sheets │────▶│ Apps Script Trigger │
│ (HR fills) │ │ (responses) │ │ (onFormSubmit) │
└──────────────┘ └──────────────────┘ └──────────┬──────────┘
│
┌────────────────────┼────────────────────┐
│ │ │
▼ ▼ ▼
┌──────────┐ ┌──────────┐ ┌──────────┐
│ Admin SDK│ │ Gmail │ │ Calendar │
│ Directory│ │ (notify) │ │ (event) │
└──────────┘ └──────────┘ └──────────┘
| Feature | Description |
|---|---|
| User Creation | Creates Google Workspace accounts via Admin SDK Directory API |
| User Suspension | Suspends accounts on offboarding — not deleted, re-enable anytime |
| Group Membership | Adds users to multiple Google Groups automatically |
| Email Notification | Sends welcome email to employee's personal address |
| Calendar Reminder | Creates an event for managers on employee start date |
| Single Trigger | One onFormSubmit dispatcher routes Create login / Revoke Access |
| Script Properties | No hardcoded IDs — configure via Project Properties |
| Error Handling | try/catch per operation, status column, admin notifications |
| Idempotent | Uses e.namedValues from the form event (no race condition on lastRow) |
google-workspace-user-management-apps-script/
├── onFormSubmit.js # Entry point: dispatcher, config, password, error helpers
├── addUser.js # Onboarding: create user, add to groups, notify, calendar
├── suspendUser.js # Offboarding: suspend user account
├── LICENSE
├── CONTRIBUTING.md
└── README.md
- A Google Workspace account with admin privileges
- Admin SDK Directory API enabled
Create a Google Form with these fields (exact names matter — they become keys in e.namedValues):
| Field Name | Type | Example |
|---|---|---|
Choice |
Multiple choice | Create login, Revoke Access |
Start Date |
Date | 01/01/2025 |
Company Email |
Short answer | john.doe@company.com |
First Name |
Short answer | John |
Last Name |
Short answer | Doe |
Department |
Short answer | Engineering |
Manager Email |
Short answer | manager@company.com |
Groups |
Short answer | all@company.com,eng@company.com |
Personal Email |
Short answer | john.doe@gmail.com |
- Open the linked Google Sheets responses spreadsheet
- Go to Extensions > Apps Script
- Create three script files and paste:
onFormSubmit.js(entry point + helpers)addUser.js(onboarding logic)suspendUser.js(offboarding logic)
- Go to File > Project Properties > Script Properties and add:
| Property | Value |
|---|---|
HR_EMAIL |
hr@yourcompany.com |
COMPANY_NAME |
Your Company |
ADMIN_EMAIL |
admin@yourcompany.com (optional, for error alerts) |
STATUS_COLUMN |
K (optional, defaults to K) |
Go to Triggers (clock icon) > Add Trigger:
| Function | Event Source | Event Type |
|---|---|---|
onFormSubmit |
From spreadsheet | On form submit |
Only one trigger is needed. The dispatcher reads the
Choicefield and routes accordingly.
Run onFormSubmit once manually to trigger the OAuth consent screen. Authorize:
https://www.googleapis.com/auth/admin.directory.userhttps://www.googleapis.com/auth/groupshttps://www.googleapis.com/auth/script.send_mailhttps://www.googleapis.com/auth/calendar.eventshttps://www.googleapis.com/auth/spreadsheets
Submit a form with "Create login". The script:
- Creates the user in Google Workspace
- Adds them to the specified Google Groups
- Sends a welcome email to their personal address
- Creates a calendar event on the start date
- Writes
SUCCESS - User createdin the status column
Fill the form with Create login. The onFormSubmit trigger calls addUser automatically.
Fill the form with Revoke Access. The onFormSubmit trigger calls suspendUser.
The user is suspended, not deleted. Data (email, Drive files) is preserved.
This script currently suspends the user account. It does not:
- Transfer Drive files to another user
- Revoke OAuth tokens or application-specific passwords
- Remove the user from Google Groups
- Delegate mailbox access
- Set up auto-reply
- Reset the user's password
For a full offboarding checklist, extend suspendUser.js with the operations your organization requires.
| Scenario | Behavior |
|---|---|
| User creation fails | Throws immediately, status = FAILED, admin notified |
| Group addition fails | Logged, non-blocking, status = PARTIAL with details |
| Welcome email fails | Logged, non-blocking, status = PARTIAL with details |
| Calendar event fails | Logged, non-blocking, status = PARTIAL with details |
| Missing required fields | Throws with descriptive message |
Failed submissions are logged via Logger.log(). If ADMIN_EMAIL is configured, the admin receives an email with the error and submitted values.
Edit the body in addUser.js:
var body = 'Dear ' + firstName + ',\n\n...';Edit the event object in addUser.js:
var event = {
summary: 'New employee starts today!',
start: { dateTime: relativeDate(9, startDate).toISOString() },
// ...
};Change the STATUS_COLUMN Script Property (default: K). The column is computed dynamically — no need to edit code.
- Replace hardcoded spreadsheet ID with Script Properties
- Replace fixed column letters with
e.namedValues - Single
onFormSubmitdispatcher - Execution status column in Google Sheets
- Error handling and admin notifications
- Improved temporary password generation (
Utilities.getUuid()) - Group removal on offboarding
- Session / OAuth token revocation examples
- Drive transfer guidance
-
.claspsupport for local development (clasp push/clasp deploy) - Screenshots of Google Form and Apps Script setup
See CONTRIBUTING.md for guidelines on setup, code style, and pull requests.
- Admin SDK Directory API Quickstart
- Apps Script Documentation
- PropertiesService
- AdminDirectory Class
- SpreadsheetApp Class
- MailApp Class
- CalendarApp Class
MIT — See LICENSE for details.