Tuesday, 25 February 2014

Learning to Program In Google Apps Script (Part 1)

google-chromebook-logo

Setting up Google Apps Script


The first thing that needs to be done is to Install the Google Apps Script web app from the Chrome Store, using the web app for Apps Script will prevent you from losing the bookmark in your bookmarks folder in Chrome and will make it easier to open Google Apps Script when you're using Chrome OS as you'll be able to pin it to the Chrome OS Shelf.

The Google Apps Script IDE


The Google Apps Script may look lightweight and simple when you first open it, but from reading what Apps Script can do on the Google Developers Apps Script tutorial site it looks like a very powerful scripting language.

Creating a first Script


Google Apps Script is based on the JavaScript scripting language so anyone proficient in JavaScript should feel right at home and only need to learn how to use the Google specific pieces of code to write a script or customization. for anyone who doesn't know how to code in JavaScript the I'd recommend using the tutorials here and set up your workspace so you can follow the tutorials without having to switch between Chrome and Google Apps Script (if you're using Chrome OS I'd even alter the resolution of your Chromebook, Chromebox or Chromebase so that you can snap Chrome and Google Apps script to the sides without any overlap 1536x864 resolution, it's not the best for playing YouTube videos, but if you need to maximize your screen real estate then it'll be ok, just remember to drop down to the recommended resolution when you've finished )

The first script in the tutorials


The first script in the tutorials is a simple one, but when I tried it I keep getting an error saying TypeError: Cannot find function getbody in object Document. (line 6, file "Code")

[caption id="attachment_1954" align="aligncenter" width="300"]Error message Error message[/caption]

But yet if I copy and past the code into the Apps Script editor it works without any problems what so ever.

Extending Google Sheets


The second example in the tutorials is a simple case of downloading a sample Google Sheets Spreadsheet into your Google Drive library and copying the sample code into the Apps Script editor and following the tutorial instructions for running the script. it doesn't teach you much in the way of coding the particular Script but you can always look through the code that you've copied at your leisure, but the tutorial shows you some of the advanced scripts & customization that you can do with Apps Script.


In the next part I'll go through another two maybe three of the tutorials from the Google Developers website.


Roland


Next


Google+

Advertisement

BBC News - Sheffield & South Yorkshire