Google Apps Script

Apps Script is a scripting language for light-weight application development in the G Suite platform. It is based on JavaScript 1.6 with some portions of 1.7 and 1.8 and provides subset of ECMAScript 5 API,[2] however instead of running on the client, it gets executed in the Google Cloud. According to Google, Apps Script "provides easy ways to automate tasks across Google products and third party services."[3] Apps Script is also the tool that powers the add-ons for Google Docs, Sheets and Slides.[4]

Apps Script
Google Apps Script
Developer(s)Google
Initial releaseAugust 19, 2009[1]
Written inJavaScript
TypeWeb application framework, scripting language
Websitescript.google.com

Benefits

  1. Based on JavaScript
  2. Cloud based debugger for debugging App Scripts in the web browser.
  3. It can be used to create simple tools for an organization's internal consumption.
  4. It can be used to perform simple system administration tasks.
  5. Community-based support model. [2]

Limitations

  1. Processing limitations – As a cloud-based service, Apps Script limits the time that a user's script may run, as well as limiting access to Google services.[5]
  2. Currently Google Apps Store does not allow direct connection to internal (behind-the-firewall) corporate databases, which is key to building business apps, however, via use of the JDBC service, this can be overcome, if connections are allowed from Google servers to the internal database server.[6] Similarly, lack of other connectivity, such as LDAP connectivity, limits the level to which GAS can be used in the enterprise.
  3. Due to the cloud nature of Apps Script, functions related to date and time will produce results that seem to be incorrect due to the data crossing time zones. Using Date/Time objects and functions without very precise declaration and thorough testing may result in inaccurate results.[7]

Example

The following code uses the Apps Script UI Services and DocList Services to display contents of a Google Drive folder in Tree format.

Notice the use of JavaScript and the use of Google Web Toolkit widgets (Google also introduced the HTML Service in June 2012, as an alternative to GWT widgets. It lets you serve web pages that can interact with server-side Apps Script functions).

function doGet(e) {   
  var app = UiApp.createApplication();
  var scrollPanel = app.createScrollPanel(); // Scroll Panel is a Google Web Toolkit Widget
  tree = app.createTree(); // Tree is a Google Web Toolkit Widget
  tree.addItem(buildTree(app, "Enterprise 2.0 - Saqib"));
  scrollPanel.add(tree);  
  scrollPanel.setHeight("500");
  app.add(scrollPanel);
  return app;
}
 
function buildTree(a, searchTerm) {
  var tree = a.createTreeItem(); // TreeItem is Google Web Toolkit Widget
  tree.setText(searchTerm);

  // Use of the Apps Script DocList Service to retrieve the collections.
  var folders = DocsList.getFolder(searchTerm).getFolders(); 
  for (var i = 0; i < folders.length; i++) {
    tree.addItem(buildTree(a, folders[i].getName())).setState(true, true);
  }

  var files = DocsList.getFolder(searchTerm).getFiles();
  for (var i = 0; i < files.length; i++) {    
    if (files[i].getType() === "document") {
      urlBase = "https://docs.google.com/document/edit?id=";
      iconHTML = "https://docs.google.com/images/doclist/icon_7_document_list.png";
    } 
    else if (files[i].getType() === "spreadsheet") {      
      urlBase = "https://spreadsheets.google.com/ccc?key=";
      iconHTML = "https://docs.google.com/images/doclist/icon_7_spreadsheet_list.png";
    }
    else if (files[i].getType() === "presentation") {       
      urlBase = "https://docs.google.com/present/edit?id=";
      iconHTML = "https://docs.google.com/images/doclist/icon_7_presentation_list.png";
    }
    else if (files[i].getType() === "drawing") {       
      urlBase = "https://docs.google.com/drawings/edit?id=";
      iconHTML = "https://docs.google.com/images/doclist/icon_7_drawing_list.png";       
    }
    else {
      urlBase = "https://docs.google.com/fileview?id=";
      iconHTML = "https://docs.google.com/images/doclist/icon_7_generic_list.png";    
    }    
     
    var image = a.createImage(iconHTML);
    var fileLabel = a.createAnchor(files[i].getName(), urlBase+ files[i].getId());     
    var fileLabelPanel = a.createHorizontalPanel();
    fileLabelPanel.add(image);
    fileLabelPanel.add(fileLabel);     
    tree.addItem(fileLabelPanel).setState(true, true);
  }   
  return tree;   
}

Embedding HTML in GAS with a GWT Widget:[8]

function doGet() {
  var app = UiApp.createApplication();
  app.add(app.createHTML("<b>Hello World!</b>"));
  return app;
}

Add-ons

In March 2014, Google introduced add-ons for Docs and Sheets (soon followed by Forms). The add-on stores let users add extra features to Google editors, such as mail-merging, workflows, diagrams builders,... All add-ons are either 100% built with Apps Script or simply use Apps Script to display a UI in the Google editors while relying on an external backend to perform some tasks. For example, MailChimp, a mail-merging tool, has an add-on for Google Docs that communicates with MailChimp platform to send emails.

Before add-ons, it was possible to publish scripts for Google Sheets in the Script Gallery. When users installed scripts through this gallery, a copy of the Apps Script code was installed on the user's Sheet. With add-ons, the source code is not visible to the end user and everyone is using the latest version published by the developer. This new approach make it easier to support existing code and helped convince several companies, such as MailChimp or LucidChart to invest in Apps Script.

As part of the add-ons release, Google also introduced a UI Style Guide[9] and CSS package to help developers built add-ons that integrate smoothly into the editors. Each add-on is also reviewed by Google before its publication and developers can benefit from advice from Googlers to provide a better user experience. It is not possible to embed ads in add-ons but it is possible to monetize them.[10]

See also

References

  1. ^ Meyer, David (August 20, 2009). "Google Apps Script gets green light". CNet. Retrieved 26 March 2011.
  2. ^ Kienle, Holger (May–June 2010). "It's About Time to Take JavaScript (More) Seriously". IEEE Software. 27 (3): 60–62. doi:10.1109/MS.2010.76. Retrieved 25 March 2011.
  3. ^ Google Apps Script
  4. ^ Bring a little something extra to Docs and Sheets with add-ons
  5. ^ https://developers.google.com/apps-script/guides/services/quotas
  6. ^ https://developers.google.com/apps-script/guides/jdbc
  7. ^ "Issue 1035: utilities.formatdate subtracts a day". Retrieved 17 December 2012.
  8. ^ [1] GAS HTML class documentation
  9. ^ UI Style Guide for Add-ons
  10. ^ I've started a little experiment...

External links

BigQuery

BigQuery is a RESTful web service that enables interactive analysis of massively large datasets working in conjunction with Google Storage. It is a serverless Platform as a Service (PaaS) that may be used complementarily with MapReduce.

Caja project

Caja (pronounced KAH-hah) is a Google project and a JavaScript implementation for "virtual iframes" based on the principles of object-capabilities. Caja takes JavaScript (technically, ECMAScript 5 strict mode code), HTML, and CSS input and rewrites it into a safe subset of HTML and CSS, plus a single JavaScript function with no free variables. That means the only way such a function can modify an object is if it is given a reference to the object by the host page. Instead of giving direct references to DOM objects, the host page typically gives references to wrappers that sanitize HTML, proxy URLs, and prevent redirecting the page; this allows Caja to prevent certain phishing attacks, prevent cross-site scripting attacks, and prevent downloading malware. Also, since all rewritten programs run in the same frame, the host page can allow one program to export an object reference to another program; then inter-frame communication is simply method invocation.

The word "caja" is Spanish for "box" or "safe" (as in a bank), the idea being that Caja can safely contain JavaScript programs as well as being a capabilities-based JavaScript.

Caja is currently used by Google in its Google Sites and Google Apps Script products; in 2008 MySpace and Yahoo! and Allianz had both deployed a very early version of Caja but later abandoned it.

ECMAScript

ECMAScript (or ES)

is a scripting-language specification standardized by Ecma International in ECMA-262 and ISO/IEC 16262. It was created to standardize JavaScript, so as to foster multiple independent implementations. JavaScript has remained the best-known implementation of ECMAScript since the standard was first published, with other well-known implementations including JScript and ActionScript. ECMAScript is commonly used for client-side scripting on the World Wide Web, and it is increasingly being used for writing server applications and services using Node.js.

G Suite Marketplace

G Suite Marketplace (formerly Google Apps Marketplace) is a product of Google Inc. It is an online store for web applications that work with Google Apps (Gmail, Google Docs, Google Sites, Google Calendar, Google Contacts, etc.) and with third party software. Some Apps are free. Apps are based on Google APIs or on Google Apps Script.

Google APIs

Google APIs is a set of application programming interfaces (APIs) developed by Google which allow communication with Google Services and their integration to other services. Examples of these include Search, Gmail, Translate or Google Maps. Third-party apps can use these APIs to take advantage of or extend the functionality of the existing services.

The APIs provide functionality like analytics, machine learning as a service (the Prediction API) or access to user data (when permission to read the data is given). Another important example is an embedded Google map on a website, which can be achieved using the Static maps API, Places API or Google Earth API.

Google App Engine

Google App Engine (often referred to as GAE or simply App Engine) is a web framework and cloud computing platform for developing and hosting web applications in Google-managed data centers. Applications are sandboxed and run across multiple servers. App Engine offers automatic scaling for web applications—as the number of requests increases for an application, App Engine automatically allocates more resources for the web application to handle the additional demand.Google App Engine is free up to a certain level of consumed resources and only in standard environment but not in flexible environment. Fees are charged for additional storage, bandwidth, or instance hours required by the application. It was first released as a preview version in April 2008 and came out of preview in September 2011.

Google Developer Expert

A Google Developers Expert (GDE) is a person recognized by Google Inc. as having exemplary expertise in one or more of their Google Developers products. GDEs are awarded through the Google Developers Experts program established and administered by Google. GDEs have a tenure of one year which can be extended through re-interview. A Google Developers Expert cannot be a Google employee whilst a member of the program. GDEs are not permitted to "make any statements on behalf of Google or any Google company" and be clear that any opinions are not those of Google.As of February 2019, there are 738 people with this designation

Google Docs

Google Docs is a word processor included as part of a free, web-based software office suite offered by Google within its Google Drive service. This service also includes Google Sheets and Google Slides, a spreadsheet and presentation program respectively. Google Docs is available as a web application, mobile app for Android, iOS, Windows, BlackBerry, and as a desktop application on Google's ChromeOS. The app is compatible with Microsoft Office file formats.

The application allows users to create and edit files online while collaborating with other users in real-time. Edits are tracked by user with a revision history presenting changes. An editor's position is highlighted with an editor-specific color and cursor. A permissions system regulates what users can do. Updates have introduced features using machine learning, including "Explore", offering search results based on the contents of a document, and "Action items", allowing users to assign tasks to other users.

Google Sheets

Google Sheets is a spreadsheet program included as part of a free, web-based software office suite offered by Google within its Google Drive service. The service also includes Google Docs and Google Slides , a word processor and presentation program respectively. Google Sheets is available as a web application, mobile app for Android, iOS, Windows, BlackBerry, and as a desktop application on Google's ChromeOS. The app is compatible with Microsoft Excel file formats.

The app allows users to create and edit files online while collaborating with other users in real-time. Edits are tracked by user with a revision history presenting changes. An editor's position is highlighted with an editor-specific color and cursor and a permissions system regulates what users can do. Updates have introduced features using machine learning, including "Explore", offering answers based on natural language questions in a spreadsheet.

Google Sites

Google Sites is a structured wiki- and Web page-creation tool offered by Google.

The goal of Google Sites is for anyone to be able to create simple web sites that support collaboration between different editors.

Google Slides

Google Slides is a presentation program included as part of a free, web-based software office suite offered by Google within its Google Drive service. The service also includes Google Docs and Google Sheets, a word processor and spreadsheet respectively. Google Slides is available as a web application, mobile app for Android, iOS, Windows, BlackBerry, and as a desktop application on Google's ChromeOS. The app is compatible with Microsoft PowerPoint file formats.Slides allows users to create and edit presentations online while collaborating with other users in real-time. Edits are tracked by user with a revision history that tracks changes to the presentation. Each editor's position is highlighted with an editor-specific color/cursor and the system regulates what users can do through varying degrees of permissions. Updates have introduced features using machine learning, including "Explore", offering suggested layouts and images for presentations, and "Action items", allowing users to assign tasks to other users.

Index of JavaScript-related articles

This is a list of articles related to the JavaScript programming language.

JavaScript

JavaScript (), often abbreviated as JS, is a high-level, interpreted programming language that conforms to the ECMAScript specification. It is a programming language that is characterized as dynamic, weakly typed, prototype-based and multi-paradigm.

Alongside HTML and CSS, JavaScript is one of the core technologies of the World Wide Web. JavaScript enables interactive web pages and is an essential part of web applications. The vast majority of websites use it, and major web browsers have a dedicated JavaScript engine to execute it.

As a multi-paradigm language, JavaScript supports event-driven, functional, and imperative (including object-oriented and prototype-based) programming styles. It has APIs for working with text, arrays, dates, regular expressions, and the DOM, but the language itself does not include any I/O, such as networking, storage, or graphics facilities. It relies upon the host environment in which it is embedded to provide these features.

Initially only implemented client-side in web browsers, JavaScript engines are now embedded in many other types of host software, including server-side in web servers and databases, and in non-web programs such as word processors and PDF software, and in runtime environments that make JavaScript available for writing mobile and desktop applications, including desktop widgets.

The terms Vanilla JavaScript and Vanilla JS refer to JavaScript not extended by any frameworks or additional libraries. Scripts written in Vanilla JS are plain JavaScript code.Although there are similarities between JavaScript and Java, including language name, syntax, and respective standard libraries, the two languages are distinct and differ greatly in design. JavaScript was influenced by programming languages such as Self and Scheme.

List of filename extensions (F–L)

This alphabetical list of filename extensions contains standard extensions associated with computer files.

List of programming languages

The aim of this list of programming languages is to include all notable programming languages in existence, both those in current use and historical ones, in alphabetical order. Dialects of BASIC, esoteric programming languages, and markup languages are not included.

List of server-side JavaScript implementations

This is a list of server-side JavaScript implementations.

Server-side scripting

Server-side scripting is a technique used in web development which involves employing scripts on a web server which produce a response customized for each user's (client's) request to the website. The alternative is for the web server itself to deliver a static web page. Scripts can be written in any of a number of server-side scripting languages that are available (see below). Server-side scripting is distinguished from client-side scripting where embedded scripts, such as JavaScript, are run client-side in a web browser, but both techniques are often used together.

Server-side scripting is often used to provide a customized interface for the user. These scripts may assemble client characteristics for use in customizing the response based on those characteristics, the user's requirements, access rights, etc. Server-side scripting also enables the website owner to hide the source code that generates the interface, whereas with client-side scripting, the user has access to all the code received by the client. A down-side to the use of server-side scripting is that the client needs to make further requests over the network to the server in order to show new information to the user via the web browser. These requests can slow down the experience for the user, place more load on the server, and prevent use of the application when the user is disconnected from the server.

When the server serves data in a commonly used manner, for example according to the HTTP or FTP protocols, users may have their choice of a number of client programs (most modern web browsers can request and receive data using both of those protocols). In the case of more specialized applications, programmers may write their own server, client, and communications protocol, that can only be used with one another.

Programs that run on a user's local computer without ever sending or receiving data over a network are not considered clients, and so the operations of such programs would not be considered client-side operations.

Overview
Advertising
Communication
Software
Platforms
Hardware
Development
tools
Publishing
Search
(timeline)
Events
People
Other
Related

This page is based on a Wikipedia article written by authors (here).
Text is available under the CC BY-SA 3.0 license; additional terms may apply.
Images, videos and audio are available under their respective licenses.