Get the Active Row as an Object
Menu actions and sidebar handoffs usually care about the row you're on, not the whole grid. getActiveRowAsObject reads the header row plus…
Get the Active Row as an Object
Menu actions and sidebar handoffs usually care about the row you're on, not the whole grid. getActiveRowAsObject reads the header row plus…
Copy a Template Sheet Tab
Copying last month's client tab inherits junk formulas, stale sample rows, and mystery filters. Keep a clean template tab, then…
Email Yourself an Error Alert
Nightly jobs that "mostly work" fail quietly until a teammate notices bad data. emailErrorAlert sends you a plain Gmail with the error…
Budget Apps Script quotas like a grown-up
Apps Script quotas aren't a surprise if you treat them like a budget. UrlFetch calls, email sends, spreadsheet reads, and total runtime all…
Get or Create a Nested Drive Folder Path
One folder name isn't enough when exports land under Exports/2026/09 or Clients/Acme/Incoming. Walk a slash-separated path from a parent…
Confirm a Dangerous Action (Yes/No)
Custom menus that Clear, Re-import, or Archive should not fire on a misclick. This thin wrapper around SpreadsheetApp.getUi().alert returns…
Build a Header → Column Index Map
Hard-coding column letters (C, D) breaks the moment a client inserts a column. Build a { headerName: columnIndex } map once from row 1, then…
Re-run your import without duplicating rows
Imports fail halfway. APIs page slowly. Someone clicks the menu twice. If "run again" means double every row, you don't have an importer…
Move a Row to Another Sheet
"Delete" is usually the wrong word. Archive the row to another tab (or workbook tab), then remove it from the working sheet — so audits…
Ensure Header Row Exists
Importers and upserts assume row 1 is headers. Empty tabs and "someone deleted column C" both break that. This helper creates the header row…
withScriptLock Helper
Standalone projects and library code don't get a Document Lock. When the critical section is the script project itself — watermark updates…
A Log sheet you’ll actually read later
Logger.log is fine until you need yesterday's failure and the Executions page shrugged. A tiny Log sheet — timestamp, level, message…
Catch a webhook in Apps Script without losing the payload
Webhooks don't retry politely when your script throws mid-flight. A solid Apps Script receiver does four boring things well: accept doPost…
Send an HTML Email with GmailApp
GmailApp.sendEmail can send HTML — you just need htmlBody (and a plain-text fallback for picky clients). This helper wraps the options bag…
Upsert a Row by Key Column
Find a row by a key column (email, order ID, SKU) and update it — or append if it's new. Header-aware, so you pass a plain object instead of…
Get the Last Data Row in a Column
getLastRow() happily counts formatting, old formulas, and phantom blanks. When you need the real last cell with data in a column — for…
Custom functions that don’t thrash your sheet
Custom functions look like spreadsheet superpowers until one volatile formula starts refetching an API on every edit. Use them for pure…
withUserLock Helper
Document locks serialize everyone on a spreadsheet. User locks only serialize the same user's overlapping runs — handy for personal quotas…
Convert Sheet Values to CSV Text
Need a CSV string for email attachments, Drive dumps, or API uploads? Escape commas/quotes/newlines correctly, then join rows. These two…
HtmlService Template Include Helper
Splitting HTML dialogs into Dialog.html + Styles.html + Client.js.html keeps IFRAME UIs maintainable. The classic pattern is a server-side…
Show a Sheet Toast for Progress
Long-running menu actions feel broken without feedback. SpreadsheetApp.toast pops a small notice in the lower-right — perfect for "started…
Get or Create a Drive Folder by Name
Exports, backups, and client drop folders all need a stable place in Drive. This returns the first child folder with that name under a…
Delete Triggers by Handler Name
Re-running an install function without cleanup creates duplicate triggers — and suddenly your sync fires five times. This deletes every…
Create a Daily Time-Driven Trigger
Time-driven triggers are how most overnight syncs stay hands-off. This helper creates a once-per-day trigger for a named function around the…
Cache JSON with a TTL
Hitting the same API or expensive sheet scan every trigger run burns quota. CacheService gives you a short-lived store (max ~6 hours…
Store and Load JSON in Script Properties
Script Properties are great for small config blobs — tokens, last-run watermarks, feature flags. These helpers wrap JSON.stringify / JSON…
Append an Object as a Sheet Row
When your data is already a plain object (API payload, form values), aligning it to row-1 headers beats hand-building arrays. Missing keys…
Clear a Sheet but Keep Header Row
Wiping a sheet before a fresh import is common — but you usually want the header row to survive. This clears content below the header(s…
Get or Create a Sheet by Name
Need a tab that might not exist yet? This helper returns the sheet if it's there, or inserts it and returns the new one — no null checks…
rowsToObjects and objectsToRows
Sheet data is easiest as a 2D array. Business logic is easier as objects keyed by header. These two helpers convert back and forth without…
withDocumentLock Helper
When a time-driven trigger and a manual run can overlap — or two editors kick the same sync — you need a lock. This helper wraps LockService…
Retry UrlFetch with Exponential Backoff
Flaky APIs and 429s are part of bootstrapper life. This helper wraps UrlFetchApp.fetch with exponential backoff so a single blip doesn't…
Timezone-safe dates in Sheets and Apps Script
new Date() in Apps Script, a date cell in Sheets, and a teammate in another city will happily disagree by a day — and you'll spend an…
Script Properties for bootstrapper config
Hardcoding an API key in the script editor feels fine… until you share the project, clone it for another client, or paste the same file into…
Batch writes without timeouts
When a script dies halfway through writing thousands of rows, you don't need a fancier API — you need a boring pattern: lock, chunk…
For Loop Using Dynamic Set
What Does This Code Snippet Do? Unlike the incremental For Loop where you specify the number of iterations you want the loop to execute…
For Loop Using Increments
What Does This Code Snippet Do? This code snippet is a basic For Loop that takes in a set iteration length and also lets you specify where…
Find the Max Length of Nested Arrays
What Does This Code Snippet Do? This findMaxLengthOfNestedArrays() code snippet takes an array of arrays (aka nested arrays) and calculates…
Find Column Number By Column Header Name
What Does This Code Snippet Do? This getColumnByName() code snippet is a fast and efficient way to quickly identify the Column Index of a…
Lookup The Matching Row Index Using a Search Term
This snippet is very helpful when you need to make updates to a specific row in a Google sheet and have an identifier that you can use to…
Converting Columns between a Number or a Letter
When you're scripting in Google Apps Script to automate data in a Google Sheet, you'll be working with Columns a lot. Sometimes you'll get…
Making a Word Game w/ Google Sheets and Apps Script
There's a Word Game that's gone viral and tons of clones are coming out for it - even ones using Google Sheets! But... they're only using…
How to Auto-Send Emails on a Google Form Submission
Are you using Google Forms and wish you could send auto-replies to your form responders? Better yet, how about personalized auto-reply…