Like Quertime on Facebook!

20 Most Sought After Google Apps Scripts

Posted on by in Mobile

There is something about the Google Apps Scripts that we should all learn. This happens to be the newest obsession, i.e. Google Apps Scripts. What you do is you add a certain code to a Google document so that you renders it capable of doing mystical things straight from the world of Doctor Strange (um… Marvel reference). The best part about Google Apps Scriptsis that you don’t have to be a seasoned coder/programmer in order to understand and be successful at it.


To be able to delve into Google Apps Scripts you need to be aware, at least a bit about JavaScript. There are websites online which you can search and refer to for JavaScript tutorial, but as stated above, you don’t have to drink the entire contents of the cup to be really in control when coding Google Apps Scripts.

Here are the 20 most sought after Google Apps Scripts:

First, let us understand what function, in a scripting environment is. It is basically a step you want a computer to perform for you. A number of functions put together in a code can get your computer to do many things for you.

Once setup, these functions can be reused. When assigning a function, remember a function starts with the word function in all lower case followed by the name of your function with a set of empty parenthesis, followed by a set of curly braces {}.


functionmyFunction() {}

This is the standard notation for writing code. Usually, it is written in between the curly brackets.



We are all aware of what a semi-colon does but from a programmer’s perspective, it goes at the end of your line denoting that the code at hand is complete.



Commenting is different with coding. When you put a couple of slashes in front of the line, only then you can comment. This is to ensure that your computer does not read this as a code. By adding comments you explain why you decide to code in a certain way for others to interpret.


var name = code;

As part of the variable, your aim is to pin down as few lines of code as possible. The idea is not to repeat the code instead utilize a variable to define a line of code so that it can be reused time and again.

The procedure is by commencing the line of code with ‘var’ in lower case and then the name of your variable (has to be one word), an equal sign, code, and ending it with a semi-colon.


Var doc = DocumentApp.getActiveDocument();

In order to be working with DocumentApp, it is essential that you define the variable. The first line of code will be engulfed in the curly brackets of your function (remember function, above?).



The dot has its own significance and in the script, it’s there to keep the directions of the stacks together. Navigate from here to there but keep these stacks tightened together with the Dot or as it is commonly known as aperiod.

Active Document codes

For Active Document, following scripts will be referred to and it may be that you will have to consult the documentation every time you try to learn in applying Google Apps Scripts.



This enables you to create a new document and also allows you to return to the document.


getActiveDocument ( )

Any container-bound script can be returned to with this method.


getUi ( )

You can return back from the script that has enabled you to add features like menus, dialogs, and sidebars. By returning it means that it will render that part of the document available that has been exposed to the script and has a user-interface environment.


openById (id)

The document can be retrieved with any specific ID.


openByUrl (url)

As the name implies it lets you open and return the document with a specified URL.

If you look at the codes above you will realize that there are exact phrases of what you want to code and that gives Google Apps Scripts an edge. For Google Documents, you will find that it is relatively easier to code.

Next Line code

For entering the next line, simply press enter and we are all set. The script needs to be told that it needs to be treated as a separate document and that a new name should be assigned to it.


doc.setName(‘I have changed the name’);

Refer to the screen below.


A list of Text Strings (technically, not codes)

A text string is made up of letters or numbers which are essentially not a part of the code. But the idea is to enclose your text string(s) in thesolo word. For this, we rename the document with a text string so this slice of the script stays in single quotes.



It tailors your document title to whatever you wish it to be called.


getId ()

You can retrieve the document’s unique identifier.


getName ()

If you intend to retrieve the title of your document, insert the captioned string.


getUrl ( )

The captioned script calls for the retrieval of the current document.


saveAndClose ( )

It enables to save the document at hand.

Therefore when playing with Google Apps Scripts and especially after having written it, make sure to save your document from the icon in thetoolbar. Name the file anything you prefer then choose to run thescript. It will process for a bit and display the output. You can then finally exit the script editor and viola! You have a Google Apps Scripts at your disposal to be employed.

To close off, let us dig in few other scripts such as


getNamedRanges ( )

willsort all of the objects with NamedRange.


getViewers ( )

Displays the list of viewers and commenters of the document.


removeEditor (emailAddress)

Will enable removal of the list of editors from the given document
And so and so forth.

Author: Joe Pirest is a tech junkie and is a digital nomad by profession.

Tags: , , ,

Comments are closed.