• Got Sheet
  • Posts
  • What's the Deal with Apps Script?

What's the Deal with Apps Script?

A primer and a question

In today’s email:

  1. overview of Google Apps Script (brief)

  2. question for you (important)

SPONSOR

Convert PDFs to Excel fast. Automate repetitive tasks without leaving the comfort of your spreadsheet. Try Lido now.

MAIN ARTICLE

What is Google Apps Script?

Like everything I gravitate toward, Apps Script is a way to automate things. It’s built into Google Sheets and lets us cut some corners and save time.

Apps Script lets us code behind the scenes in Google Sheets. It’s a way to expand the capabilities of Google Sheets beyond the built-in functions.

Do You Have to Code to Use Apps Script?

Yes. But wait! Don’t despair!

Apps Script is a scripting language based on JavaScript. There’s nothing you have to install, the code editor is built into Google Sheets, there are tons of premade methods (small pieces of code that do certain things) and running the code is easy.

Apps Script is not just for Google Sheets, either. It’s a Google Workspace product and is built to work with and connect all the apps you’re used to: Sheets, Docs, Forms, Maps, etc.

What Can You Do With Apps Script?

I’ve built automations with Google Calendar, Google Forms and Google Sheets. And even a game or two.

You can trigger certain things to happen in another program (like sending an email in Gmail from a Sheet, for example).

I’ve added custom menus, sidebars, pop-ups, functions and more.

You can do simple things like clearing many ranges to reset a template.

You can do complicated things like publish web apps.

You can add a button to your Google Sheet and feel the satisfaction of automations running in the background whenever you click it.

Why Should You Care?

Solopreneurs and founders are no strangers to recurring tasks. Automating stuff I have to do on a regular basis is the number one reason I use Apps Script.

You can:

  • Send daily email summaries from Sheets automatically

  • Create your own spreadsheet formulas

  • Pull data from APIs into Google Sheets

  • Auto-generate reports or documents

  • Build bespoke mini tools to simplify your operations

Your First Script - DO THIS!

If you’re intimidated or don’t know anything about coding, do this. It’ll only take a minute, and it’ll illustrate the ease of getting started with Apps Script.

A lot of programming languages require integrated development environments or complicated setup processes.

I want you to just open up a new Google Sheet. Go to https://sheets.new/

Once there, open up Apps Script by selecting Extensions -> Apps Script from the menu.

Apps Script menu

Now you’re in the Apps Script code editor.

On the left side of the screen, you’ll see a navigation bar where you can access other tools like triggers, settings and project history.

Don’t worry about all that.

In the code editor on the right side, you’ll see the beginnings of a function are already written:

function myFunction() {
  
}

A function is a set of instructions that tell the program to do something. In this case, it’s declaring a function named myFunction.

Everything between the curly braces will be the instructions. Right now, it’s blank, but let’s make a classic Hello, World function so that the words, ‘Hello, World’, are printed out on the screen.

In between the curly braces, type or paste the following line (you can just copy and paste the whole thing and replace what’s in your code editor):

function myFunction() {
  SpreadsheetApp.getActiveSpreadsheet().toast('Hello, World!');
}

Don’t forget to save! You can press CTRL+S or click the little save icon in the toolbar above the code editor.

Why Did We Write So Little?

The beautiful thing about Google Apps Script is that there are tons of built in functions to help us do common things.

Yes, the more custom we make things, the more code we’ll need to write, but there are tons of pre-built code in the Apps Script documentation to get started with.

Particularly for stitching together different Google Workspace services.

But that’s getting a little ahead of ourselves.

Let’s explain this code line by line.

Hello World Apps Script Explanation

Here’s what it does, line by line:

  • function myFunction() creates a reusable action called "myFunction."

  • Inside the function, the code runs one command:

    • SpreadsheetApp.getActiveSpreadsheet().toast('Hello, World!');

Here’s the breakdown:

  • SpreadsheetApp is a built-in tool that gives you access to Google Sheets.

  • .getActiveSpreadsheet() is a method that gets the currently open spreadsheet.

  • .toast('Hello, World!') is another method that shows a small popup message in the bottom right corner.

So, this line is a method chain: one method gets the spreadsheet, and the next method shows a message in it.

Run the Code

Now let’s run the code to see it in action.

Click the triangle Run button at the top:

Wait a sec, what’s this Authorization required box that popped up??

Don’t worry. This is normal. Anytime you first run a script, you must give Google permission to do so.

  • Click Review permissions

  • Select your Google Account

  • Click Advanced

  • Click Go to <your-project-name> (unsafe)

  • Click Continue

Boom—you've just run your first script.

Where Does it Run?

But, what happened? Nothing.

You should see an execution log at the bottom that says “Execution started” and “Execution completed”.

That’s good. That means the code didn’t have any errors. But, where is our ‘Hello, World!’ text?

Click back to the spreadsheet itself. When we went into Apps Script, it opened up in a new browser tab.

In the bottom right of the spreadsheet, you should see a pop-up box with the ‘Hello, World’ message.

Hello world pop up box in Sheets

Want to Learn More?

I’ve made several videos on the topic already. Check them out in this playlist.

I’ve got articles on Got Sheet as well. Check them out here.

Do You Want a Dedicated Beginner's Course for Apps Script?

Click Yes and I'll add you to early access.

Login or Subscribe to participate in polls.

NEXT STEPS

Whenever you’re ready, here’s how I can help:

  1. Business tech stack (FREE)
    My recommendations for software and tools I use to create content and run my online business.

  2. Sponsor Got Sheet
    Got Sheet teaches business operators, teachers and entrepreneurs how to get good at spreadsheets. Interested in sponsoring an issue or a series of Got Sheet newsletters? Reach out to get more information.

  3. Personal budget tool
    As a Got Sheet subscriber, I want you to have a 50% discount on the personal finance system I update every year.

  4. YouTube

    If you aren’t subscribed yet, come on over to my YouTube channel where I make all my spreadsheet, coding and productivity tutorials

HAPPY SPREADSHEETING!

Enjoyed this issue?
Subscribe below or Leave a testimonial

Cheers, Eamonn
Connect on LinkedIn, YouTube & Twitter.

Reply

or to participate.