Google Workspace Automation7 min read
Google Apps Script for Beginners: Your First Custom Function
A first-time walkthrough of Google Apps Script — where to write it, how to run it, and how to build a simple custom function for Google Sheets.
By The Research Desk Editorial Team · Published 18 August 2026
What Apps Script Actually Is
Google Apps Script is a cloud-based JavaScript platform that runs inside Google Workspace. It's not a plugin you install — it's built into every Sheet, Doc, Form, and Slides file, accessible through Extensions → Apps Script.
Anything you can do manually in Sheets or Gmail, Apps Script can do automatically: reading and writing cell values, sending emails, creating calendar events, calling external APIs, and reacting to events like a form submission or an edited cell.
Opening the Script Editor
From any Google Sheet, go to Extensions → Apps Script. This opens a separate editor tied to that specific spreadsheet — this is called a container-bound script, meaning it lives inside that file rather than existing independently.
You'll see a default file, Code.gs, with an empty myFunction(){} block. That's where your first function goes.
Writing Your First Custom Function
A custom function works like a built-in Sheets formula, except you define the logic yourself. Here's a simple one that adds a 10% service fee to a number:
- function ADDFEE(amount) { return amount * 1.1; }
- Save the script (the disk icon or Ctrl/Cmd+S)
- Back in your Sheet, type =ADDFEE(A1) into any cell
- The function runs exactly like a native formula — it recalculates automatically when A1 changes
Writing a Function That Automates an Action
Custom functions that return a value (like ADDFEE above) are one category. The other category is functions that do something — send an email, create a row, call an API — rather than return a value into a cell.
These action functions need to be run manually the first time (via the Run button in the script editor, which will prompt you to authorize the permissions it needs), or attached to a trigger so they run automatically — on a schedule, or when the sheet is edited or a form is submitted.
Understanding Authorization Scopes
The first time a script tries to do something beyond read/write the sheet it's bound to — sending an email, for example — Google will prompt you to authorize specific permission scopes. This isn't a bug or a security warning to dismiss; it's the mechanism that keeps a script from silently doing more than you approved.
Only grant the scopes a script actually needs. A script that just formats cells shouldn't be requesting Gmail send permission — if it is, that's worth questioning before you approve it.
Where to Go From Here
From this starting point, the natural next steps are: adding a time-driven trigger so a function runs automatically every morning, using UrlFetchApp to pull data from an external API into your sheet, and using SpreadsheetApp methods to read and write ranges programmatically instead of one cell at a time.
Each of those is a bigger topic in its own right — this is deliberately just enough to get a first working function on the board.