Skip to Main Content
University of York Library
Library Subject Guides

Coding: a Practical Guide

Google Apps Script

Google Apps Script

Want the Google apps to do more?

Google Apps Script is a coding language based on JavaScript that allows you to extend and manipulate Google apps like Drive, Sheets, Docs, and Gmail.

What is Apps Script?

Apps Script is a coding language designed so you can do more with Google applications like Drive, Docs, Sheets, Calendar, Gmail, and more. It is based on JavaScript and runs in the cloud rather than on your device.

It is helpful for automating things you might do in Google apps or finding creative solutions to problems.

What is JavaScript?

JavaScript is a coding language for web development, which is a fancy way of saying making web pages. It tends to be used to add interactivity and functionality to web pages, which are built using HTML and CSS to give them structure and style.

JavaScript is a scripting language, which means it creates scripts that can be run when particular 'events' or 'triggers' tell the code to run. Apps Script works the same, but instead of being based on a web page, it is based on Google Drive and can be 'bound' to particular Google files like Sheets or just exist on Google Drive as an 'unbound' script file.

It is useful to know some JavaScript concepts to work with Apps Script, as there's some features you'll need to use with Apps Script. Check out our JavaScript and jQuery page for introductory resources on JavaScript.

Apps Script works by accessing different 'apps' within your code so that you can work with Google applications and their respective features. For example, you use the SpreadsheetApp to work with features of spreadsheets and the DriveApp to work with features of Google Drive.

How do I learn Apps Script?

Apps Script is a good beginner coding language to learn if you work with Google tools, as it allows you to automate processes and do useful things without needing to learn everything about Apps Script first. The different Google apps have different Apps Script commands you can use for them, meaning you can focus on what you can do with e.g. Google Sheets or Google Drive as is relevant to you, and learn more as you want to extend your Apps Script projects.

The first thing you'll need to know about is the Google applications themselves, so we'd recommend you make sure you're familiar with using Google Drive and Docs especially, including how sharing works.

If you're a member of staff at the University of York, you can book onto a five-week Essential Apps Script course on the Learning Management System. The course starts from the basics of Apps Script and uses projects to develop your skills.

Google has created a whole site for Apps Script, which includes some guides and basics and, mostly importantly, a full reference for all of the commands you can use in Apps Script. It is a great place to find answers and learn more about Apps Script.

The guides they have start from an overview of Apps Script and then contain some quick start examples and further tutorials. If you're learning Apps Script this way, you'll also want to look at information on JavaScript separately to understand some of the other things you'll need to do to use Apps Script, like variables, loops, and if conditions.

Once you start learning Apps Script (or, indeed, any coding language), it's good to explore other people's code to see what else you can be doing or other methods for doing things you've been trying. You can look on sites like Stack Overflow to ask and answer questions about coding, or you can look at specific sites created to share code in particular languages.

Planning an Apps Script project

So, what can you do with Apps Script? How do you go about planning an Apps Script project?

If you've used Google Workspace apps, you've probably got some ideas about what you wish they could do or have processes it would be good to automate. You might want to be able to create a lot of files or folders in one go, automate things that happen from a form submission, or extend Google Sheets.

One important thing to consider is scale. For most users, Apps Script is very good for small scale solutions, but if your project would either be used more widely than just you, or would be used for larger scale or business critical processes, you might need to take extra things into consideration. If you're at the University of York, get in touch with IT via itsupport@york.ac.uk to discuss any Apps Script projects you might be looking into doing and get advice.

For more on using Google apps and what they can already do, see our Google Workspace guidance:

If you're at the University, we've created some useful tools based on Apps Script, that can be used without any coding knowledge. Check there's not already a tool out there for what you're looking to do:

What kinds of things can you do with Apps Script?

If you're learning Apps Script and want some inspiration for what you could do, here's some things that are possible with Apps Script (caution: some of these might be trickier than others to create!):

  • Bulk create Google Drive folders with specific naming conventions
  • Bulk rename Google Drive files or folders.
  • Create Google Docs from data contained in Google Sheets and store in a particular Drive location.
  • Automatically create Google Docs from a Google Form submission.
  • Send personalised emails from data contained in a Google Sheet (and add links to particular Drive files).
  • Create Calendar events from data in a Google Sheet.
  • Bulk create PDFs of Google Docs.
  • Monitor Google Sheets edits.

Exercises

If you want to have a go at writing some Apps Script, try the walkthrough below, which is designed to get you creating your own Apps Script code to 'read' a value from a spreadsheet cell.

Feedback
X