Like Quertime on Facebook!

20 Most Sought After Google Apps Scripts

Filed under 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.

google-app-scripts

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 {}.

1.

functionmyFunction() {}

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

2.

Semi-Colon;

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.

3.

//Comments

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.

4.

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.

5.

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?).

6.

Dot

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.

7.

create(name)

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

8.

getActiveDocument ( )

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

9.

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.

10.

openById (id)

The document can be retrieved with any specific ID.

11.

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.

12.

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

Refer to the screen below.

google-app-scripts-doc-setname

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.

13.

setName()

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

14.

getId ()

You can retrieve the document’s unique identifier.

15.

getName ()

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

16.

getUrl ( )

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

17.

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

18.

getNamedRanges ( )

willsort all of the objects with NamedRange.

19.

getViewers ( )

Displays the list of viewers and commenters of the document.

20.

removeEditor (emailAddress)

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

Guest Author: Joe Pirest

Realdissertationhelp.co.uk is a tech junkie and is a digital nomad by profession.

Tags: , , ,