6

I've been looking for a good way to automate my Google Docs and Sheets on Drive, buy haven't found specific answers or even general ones I can modify to work for my specific requirements. I'm doing things that tie several sheets together and track variables that update and change constantly while keeping other sheets that use those variables current.

Therefore, I'm looking for ways to learn Google Apps Script. From what I've gathered, it looks like this language has the functionality to implement what I want to do. I'm looking for web or book based methods. I googled some classes on the scripting language and they were gimmicky and short, the Google tutorials jump in without explaining the base of anything, like function calls. I have a few years of Java, C++ and Oracle SQL/PL, so learning logic or basic language methods is not a barrier. I'm looking for something comprehensive, I don't want to just learn a pigeon hole answer to my problems, I want to know a good base level.

How do you go about learning Google Apps Script, specifically about Drive Docs and Sheets?

closed as too broad by ale, Jacob Jan Tuinstra, Vidar S. Ramdal, Eight Days of Malaise, Sathyajith Bhat Nov 28 '15 at 14:38

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

4

The "Basic JavaScript Features" section in the official Apps Script documentation states that "Apps Script is based on JavaScript 1.6, plus a few features from 1.7 and 1.8." Therefore, it would be helpful to first learn the fundamentals of JavaScript, as the other answers have already mentioned.

But! It is important to keep in mind that the Apps Script environment is very different from a regular web browser, and most guides/tutorials for JavaScript will cover many topics that don't apply to Apps Script development.

Apps Script is synchronous and has no event loop. There are no callbacks, and standard browser functions like window.setInterval() don't exist. Furthermore, the Apps Script API does not feature any non-blocking methods at all -- even fetching an external URL will block until the response has been received from the remote server!

As an informal observation, much of the Apps Script platform is poorly-documented, and it can be difficult to adapt standard JavaScript libraries to work in the Apps Script environment.

Some resources that you might find helpful:

  1. The official Apps Script documentation is quite thorough and includes a number of examples and tutorials.
  2. Amit Agarwal's "How to Learn Google Apps Script" offers several useful links.
  3. The "JavaScript reference" on MDN (the Mozilla developers' wiki) is the best language reference available.
  4. You will want to refer to the official issue tracker from time to time to check for known bugs that other Apps Script users have encountered. It is sadly quite common for the official Apps Script documentation to be inaccurate and/or outdated.
3

I'll answer in greater generality, not necessarily tied to your particular background.

Step 1: Learn the fundamentals of JavaScript.

Step 2: Start using or modifying small scripts interacting with Google Sheets, keeping the official documentation open in a tab, or better in several: one tab for Spreadsheet class, one for Sheet class, one for Range. The documentation has plenty of examples. Here's one more, assumed to be bound to a Spreadsheet:

 function hello() {
   var sheet = SpreadsheetApp.getActiveSheet();
   sheet.getRange(1, 1).setValue('Hello World');
 }

Step 3: Proceed to Documents if you must, but with care; the API is more cumbersome (in my opinion) than for the Sheets, and involves writing more while doing less. Some familiarity with Document Object Model can be helpful, but often Documents are annoyingly unlike HTML.

  • I actually started learning Apps Script myself last week, and I can fully get behind this answer. Learning JavaScript first---at least the basics---is almost essential; I completed the Codecademy course, which is great. Writing apps and macros for Sheets is quite a bit simpler than for other Google Apps, given its preexisting inclination towards data manipulation and programming. ~~~ If you need ideas for where to start, check out the Apps Script overview on Google Developers. – SightSpirit Nov 24 '15 at 4:05

Not the answer you're looking for? Browse other questions tagged or ask your own question.