Concept
Two kinds of scripts
Bound script — attached to one file (a Sheet, Doc, Form or Slides).
- Created from inside the file: Extensions → Apps Script.
- Can use "active" helpers like
SpreadsheetApp.getActiveSpreadsheet(). - Can add custom menus and run
onOpen/onEdittriggers for that file. - Gets copied when someone makes a copy of the file.
Standalone script — a project on its own in Drive.
- Created at script.google.com → New project.
- Not attached to any file, so it opens files by ID:
SpreadsheetApp.openById('...'). - Good for jobs that touch many files, or for web apps.
Rule of thumb: if the automation belongs to one spreadsheet, use a bound script. If it is a tool that works across files, use standalone.
Tour of the editor
| Area | What it does |
|---|---|
| Files (left) | .gs files hold code; .html files hold pages for dialogs and web apps. Add more with +. |
| Libraries / Services | Add shared libraries or advanced Google services (e.g. Drive API). |
| Function dropdown + Run | Pick which function to run, then click Run. |
| Debug | Run step-by-step with breakpoints. |
| Execution log | Shows console.log / Logger.log output for the current run. |
| Triggers (clock icon) | Schedule functions or run them on events. |
| Executions (list icon) | History of every run, with status and errors. |
| Project Settings (gear) | Time zone, runtime, and Script Properties (for keys and settings). |
| Deploy | Publish as web app, add-on, or API executable. |
Authorization: the first-run prompt
The first time a script uses a service (Sheets, Gmail, Drive…), Google asks for permission:
- Click Review permissions and choose your account.
- For your own scripts you may see "Google hasn't verified this app". Click Advanced → Go to (project name). This is normal for personal scripts — but only do this for code you wrote or trust.
- Click Allow.
If you later add code that uses a new service, Google will ask again.
Set the time zone
Go to Project Settings and set the time zone to (GMT+05:30) India Standard Time (or yours). Dates and time-based triggers use this setting — a wrong time zone is a common cause of "my trigger ran at the wrong time".
Try it: open a sheet from a standalone script
function readFromAnotherFile() {
// Copy the ID from the sheet URL: docs.google.com/spreadsheets/d/<THIS_PART>/edit
const ss = SpreadsheetApp.openById('PASTE_SHEET_ID_HERE');
const name = ss.getName();
console.log('Opened: ' + name);
}
Key points
- Bound = lives inside one file; standalone = its own project.
- Standalone scripts open files by ID, not "active".
- Check Executions whenever something didn't work — the error is recorded there.