Orientation
Choose between bound and standalone Apps Script projects, and learn what the V8 runtime lacks and which Workspace data a script can access.
Decide whether a small Apps Script project fits a task and explain what a bound script can access.
Choose between a bound and a standalone Apps Script project, and check what a script can access before you write code. You need a Google account and a browser.
What Apps Script is
Apps Script is JavaScript that runs on Google's servers and calls built-in Google Workspace services such as Sheets, Drive, and Gmail. Google provides the Apps Script editor in the browser, stores your projects, and runs the code. Google's overview describes it as a rapid application-development platform for Workspace integrations.
Apps Script code has no window, document, browser fetch, or Node process. Use UrlFetchApp.fetch() for HTTP requests. Google's V8 runtime limitations list the remaining differences.
Choose a bound or standalone project
A bound script belongs to one spreadsheet, document, presentation, or form. In a spreadsheet, create one with Extensions > Apps Script. When the script runs from that file (from the editor, a custom menu, or a trigger), SpreadsheetApp.getActiveSpreadsheet() returns the parent spreadsheet, so the script does not need a stored file ID. The script can also add menus and dialogs to the open file.
Methods that return the active parent file, such as getActiveSpreadsheet(), are unavailable when the project runs as a web app or through the Apps Script API. You cannot detach a bound script from its file. A bound script can still use installable triggers and can be deployed as a web app. See Google's bound-script guide.
A standalone script is independent of any single Workspace file. Create one at script.google.com or from Google Drive when the script works across multiple files. It appears in Drive as its own item. It opens target files by ID, because getActiveSpreadsheet() has no parent spreadsheet to return. See Google's standalone-script guide.
| Need | Start with |
|---|---|
| Read or extend one spreadsheet that a person has open | A bound spreadsheet script |
| Work across selected Drive files, run a scheduled utility, or deploy a web app | A standalone script, or a bound script when the work centers on one file |
| Build a large public application, long-running service, or rich browser UI | Another platform, using Apps Script only where its Workspace integration helps |
Know what the script can access
Your code cannot read private Workspace data until a user authorizes it. When code calls a service such as SpreadsheetApp, Apps Script determines the required OAuth scopes, prompts the user for consent when needed, and runs with the approved access. See the authorization guide.
Read the consent screen before approving it. A function that reads a spreadsheet and one that sends Gmail or deletes Drive files request different scopes, and the consent screen lists each one. Start in a disposable spreadsheet and verify which data the function reads or changes. Never paste credentials or customer data into an example project.
Which account the code runs as depends on how the execution starts:
Running a function in the editor runs as the person at the keyboard.
An installable trigger runs as the person who created that trigger.
A web app runs as either the visitor or the script owner, depending on its deployment settings.
Later chapters state how each example starts and which account it runs as.
Continue with a small read
The next chapter creates a bound spreadsheet script that reads a Customers tab and logs its rows without changing the sheet. Follow Run your first Sheets script before modifying a live spreadsheet.