Introduction

Google Apps Script (GAS) is a cloud-based development platform that enables you to create applications that seamlessly integrate with Google Workspace apps (like Google Sheets, Docs, and Gmail) and other services.


Programmed with modern JavaScript, GAS allows you to automate tasks, create workflows, and build custom functions for Google Workspace without the need for complex setups. You can directly edit your scripts using Google’s integrated code editor, which works entirely within your web browser. Once the script is ready, it runs on google’s server and now you don't need to manage the infrastructure.


GAS functions similarly to Visual Basic for Applications (VBA) in Excel, enabling users to extend the functionality of Google Sheets and other apps by automating processes and integrating with third-party services and APIs.


What is Google Apps Script?

Google Apps Script is a robust tool for extending and automating Google Workspace apps like Docs, Sheets, Gmail, and more. It’s built on JavaScript and is designed for simplicity and accessibility, making it ideal for both beginners and professionals. 



With Apps Script, you can:

  • Create user interfaces.
  • Automate routine tasks.
  • Build custom add-ons.
  • Integrate Google apps with third-party services.

Why Use Apps Script?

  1. Ease of Use: No need to install software; everything runs in the cloud.
  2. Free to Start: As long as you have a Google account, you can start coding for free.
  3. Seamless Integration: Apps Script works perfectly with Google Workspace apps.
  4. Save Time: Automate tasks that usually take hours.

Note:  In February 2020, Google announced the V8 runtime for App Script, bringing with it full support of classes. This updated runtime allows you to create your own classes, which is essential to manage code with inheritance. Consider it as creating a blueprint or template that can be used to create multiple copies.


Getting Started with Google Apps Script

The best way to learn Google Apps Script is to write some code. Starting the App Script journey is very simple —  require just a few essentials: A Google account, a browser, and an internet connection.
connection.

Start by creating a new spreadsheet on Google Drive. Give your spreadsheet a name, for example, My First Script.

You can open the Apps Script editor by clicking Extensions > Apps Script from the menu (or Tools > Script editor if you can’t find the Extensions menu). 


This will launch the Apps Script editor in a separate tab in your browser.


How to use Google Apps Script Editor

Now, we’ll show you how to use the Apps Script editor. For example, how to rename your project, add a new function, and save your changes.


How to rename your project

Scripts are organized as projects. By default, the project name for your scripts embedded within the spreadsheet file you just created is “Untitled project”.


At the top left, you’ll see the project name. Click on it to rename it. A small window will appear, allowing you to enter a new project title.



How to add your first function

Delete the myFunction() code block so that your editor is now blank. Then, copy and paste the following code:




The above writeHelloWorld() function writes “Hello world!” to the spreadsheet. It illustrates that the spreadsheet can be managed by using Apps Script.

The code uses the SpreadsheetApp class to get an object which represents the currently active sheet by calling the getActiveSheet() method.

Then, it gets a single cell with the address A1 using the getRange() method. Another method, setValue(), is then called with a string argument to write to A1. 


How to save your changes

Notice that there is an orange circle icon on the left side of the Code.gs file name. It means your changes have not been saved yet. 


To save your changes, press Ctrl+S on your keyboard. Alternatively, you can click the disk icon (Disk icon). After that, the orange icon will be gone, and you’ll be able to run your script.


How to run Google Apps Script

Click the Run button to execute your function. For the first time you run the script, a pop-up will appear asking you to authorize it. You will need to grant permission to access your data.



click the Review permissions button. Another pop-up will appear, asking you to select an account to continue. After that, you may see a warning screen saying “Google hasn’t verified this app“. Continue anyway — because, in this case, we know it’s safe. Then, allow the script to access your Google account.


Once authorized, the writeHelloWorld() function will execute, and you’ll see “Hello world!” in A1:



Tips for Beginners


  1. Use the Documentation: Google’s Apps Script documentation is a treasure trove of examples and explanations.
  2. Start Small: Begin with simple scripts and gradually move to complex ones.
  3. Join the Community: Forums like Stack Overflow and the Apps Script Google Group are great for troubleshooting.
  4. Experiment Freely: The best way to learn is by doing. Break things and fix them—it’s all part of the process.

Conclusion

Google App Script is a powerful tool for everyone who works with or wants to start using Google Workspace. If you want to save time, dive into coding, or create custom tools, this is the perfect place to get started. Follow each step of the process from this guide to become an Apps Script expert.


Ready to get started? Open the script editor and start automating your Google Workspace today!