Skip to content
Skip to chapter

Chapter 1

Getting started

Orientation

Choose between bound and standalone Google Apps Script projects and understand the boundary between V8 code, Workspace services, and user data.

By the end

Decide whether a small Apps Script project fits a task and explain what a bound script can access.

Chapter navigation

Choose the right boundary

Apps Script is JavaScript that runs on Google's servers and can call built-in Google Workspace services such as Sheets, Drive, and Gmail. Google provides a browser editor, stores your projects, and runs the code for you. Google's overview describes it as a rapid application-development platform for Workspace integrations.

Apps Script code does not have window, document, browser fetch, or Node's process. Use UrlFetchApp.fetch() for HTTP requests. The V8 runtime limitations describe these boundaries.

Pick a project shape

A bound script belongs to one spreadsheet, document, presentation, or form. In a spreadsheet, create one with Extensions > Apps Script. When it runs in a supported bound-file context, it can refer to its parent spreadsheet with SpreadsheetApp.getActiveSpreadsheet() without storing a file ID, and it can add UI to the open parent file. Those active-file and UI methods are unavailable when the project runs as a web app or through the Apps Script API. A bound script cannot be detached from its container, though it can still use installable triggers or a web-app deployment. See Google's bound-script guide.

A standalone script is not attached to a Workspace file. Create one at script.google.com or from Drive when a container relationship does not help. It appears in Drive as its own file, opens target files by ID, and has no parent spreadsheet for getActiveSpreadsheet(). See Google's standalone-script guide.

NeedStart with
Read or extend one spreadsheet that a person has openA bound spreadsheet script
Work across selected Drive files, run a scheduled utility, or deploy a web appUsually a standalone script; use a bound script when its container relationship helps
Build a large public application, long-running service, or rich browser UIAnother platform, with Apps Script only where its Workspace integration helps

Treat access as part of the program

Your JavaScript cannot read private Workspace data until authorized. When code calls a service such as SpreadsheetApp, Apps Script determines the required OAuth scopes, prompts the executing 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 has a different effect from one that sends Gmail or deletes Drive files. Start with a disposable spreadsheet and a function whose data effect you can describe in one sentence. Do not paste credentials or customer data into an example project.

Execution identity also depends on how code starts. A function run in the editor for a bound or standalone script runs as the person at the keyboard. An installable trigger runs as the person who created that trigger. A web app can run as the visitor or the script owner, depending on deployment settings. Later chapters name both the entrypoint and the execution identity for each example.

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 changing a live spreadsheet.