World Library  
Flag as Inappropriate
Email this Article
 

Google Apps Script

Google Apps Script
Developer(s) Google
Initial release 2009 (2009)[1]
Development status Active
Written in JavaScript
Operating system Cross-platform
Type Web application framework, Scripting language
Website .com.googlescript

Google Apps Script is a cloud based scripting language for light-weight application development in the Google Apps 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, 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 & Forms.[4]

Contents

  • Benefits 1
  • Limitations 2
  • Example 3
  • Add-ons 4
  • References 5
  • External links 6

Benefits

  1. Based on JavaScript. Easy To learn.
  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. [1]

Limitations

  1. Processing limitations: as a cloud-based service, Google Apps Script limits the time that a user's script may run, as well as limiting access to Google services. [2]
  2. Currently Google Apps Script does not allow connection to internal (behind-the-firewall) corporate databases, which is key to building business apps. Similarly, lack of other connectivity, such as LDAP connectivity, limits the level to which GAS can be used in the enterprise.
  3. Google's implementation of JavaScript may be inaccurate and some functions may not return expected results.[5]

Example

The following code demonstrate use of Google 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 is 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 Google 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:[6]

function doGet() {
  var app = UiApp.createApplication();
  app.add(app.createHTML("Hello World!"));
  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, like mail-merging, workflows, diagrams builders,... All add-ons are either 100% built with Google 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, like MailChimp or LucidChart to invest in Google Apps Script.

As part of the add-ons release, Google also introduced a UI Style Guide[7] 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 advises 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.[8]

References

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

External links

  • Official website
  • /apps-script.com.googledevelopers
  • /case-studies/apps-script.com.googledevelopers
This article was sourced from Creative Commons Attribution-ShareAlike License; additional terms may apply. World Heritage Encyclopedia content is assembled from numerous content providers, Open Access Publishing, and in compliance with The Fair Access to Science and Technology Research Act (FASTR), Wikimedia Foundation, Inc., Public Library of Science, The Encyclopedia of Life, Open Book Publishers (OBP), PubMed, U.S. National Library of Medicine, National Center for Biotechnology Information, U.S. National Library of Medicine, National Institutes of Health (NIH), U.S. Department of Health & Human Services, and USA.gov, which sources content from all federal, state, local, tribal, and territorial government publication portals (.gov, .mil, .edu). Funding for USA.gov and content contributors is made possible from the U.S. Congress, E-Government Act of 2002.
 
Crowd sourced content that is contributed to World Heritage Encyclopedia is peer reviewed and edited by our editorial staff to ensure quality scholarly research articles.
 
By using this site, you agree to the Terms of Use and Privacy Policy. World Heritage Encyclopedia™ is a registered trademark of the World Public Library Association, a non-profit organization.
 



Copyright © World Library Foundation. All rights reserved. eBooks from World Library are sponsored by the World Library Foundation,
a 501c(4) Member's Support Non-Profit Organization, and is NOT affiliated with any governmental agency or department.