1 of 40

Google Apps Script:

​

The authentic{ated} playground

mobile

​

​

​

This work is licensed under a Creative Commons Attribution 4.0 Unported License. CC-BY mhawksey

+Martin Hawksey

@mhawksey

http://bit.ly/EdMobGAS

2 of 40

http://bit.ly/EdMobGAS

3 of 40

Google G Suite...

4 of 40

Google Apps Script

5 of 40

JavaScript in the cloud

Apps Script is based on JavaScript 1.6, plus a few features from 1.7 and 1.8.

6 of 40

Where..

Standalone

Sheets

Docs

Forms

Sites

7 of 40

A brief history

​

​

2009

Scripts in Sheets

Custom functions

​

​

​

​

​

​

2010

UiApp*

Web Apps (run as developer)

Script Gallery*

​

​

​

​

​

2011

Scripts in Sites

GUI Builder*

More services

​

​

​

​

​

2012

Standalone scripts

HTMLSerivce

ScriptDb*�Web Apps (run as user)

Libraries and versioning

Content Service

Chrome Web Store

​

​

2013

Scripts in Doc

Scripts in Forms

Auth flow

More services

​

​

​

​

2014

Add-on for Documents, Sheets and Forms

IFRAME for HTMLService

​

​

​

​

* Denotes deprecated services/features

​

Adapted from Wesley Chun’s Google Apps Script

​

​

2015

Execution API

​

​

​

​

​

​

​

2016

Iframe Embed

Android Add-ons

​

​

​

​

​

8 of 40

Integration

CC-BY-NC Eugen Stoll�https://flic.kr/p/5c6ce

9 of 40

One liners

10 of 40

One liners

11 of 40

One liners

12 of 40

One liners{ish}

13 of 40

Toast

14 of 40

One liners services

Calendar

Contacts

Document

Drive

Forms

Gmail

​

​

Groups

Language

Maps

Sites

Spreadsheet

15 of 40

One{ish} liners services

16 of 40

Fetch...

BY-NC-SA tarteme�https://flic.kr/p/bAoEyi

17 of 40

…fetch

UrlFetchApp.fetch(url, params);

​

This service allows scripts to access other resources on the web by fetching URLs. A script can use the UrlFetch service to issue HTTP and HTTPS requests and receive responses. The UrlFetch service uses Google's network infrastructure for efficiency and scaling purposes.

“

18 of 40

Identity

CC-BY-NC Thomas Hawk �https://flic.kr/p/bUy6wK

19 of 40

Google Apps Script Web apps

20 of 40

Google Add-ons

CC-BY gail heidel

https://flic.kr/p/65aFCx

21 of 40

Customising Sheets, Documents and Forms...

Sheets + Add-ons

Documents + Add-ons

Forms + Add-ons

22 of 40

Domain distribution

23 of 40

Android Add-ons

CC-BY gail heidel

https://flic.kr/p/65aFCx

24 of 40

… for Google Docs and Sheets

Android add-ons are apps that can be called from Google Docs or Google Sheets editor apps, and are built by developers to enhance or extend the capabilities of those editors.

“

25 of 40

The Android Add-on experience…

26 of 40

Execution API…

CC-BY-NC-ND Dizzy Girl

https://flic.kr/p/cpvb9

27 of 40

Execution API...

The Execution API is a REST interface that lets a third-party application call a function defined in an Apps Script project and receive a response. This API lets you expose the full utility of Apps Script to any application, including Android and iOS apps.

“

28 of 40

Limits…

CC-BY-NC Chris Campbell

https://flic.kr/p/5YdSeh

29 of 40

Feature

Consumer (gmail.com)

Google Apps free edition (legacy)

G Suite Basic/Business/Edu/Gov

Calendar events created

5,000 / day

10,000 / day

10,000 / day

Contacts created

1,000 / day

2,000 / day

2,000 / day

Documents created

250 / day

500 / day

1,500 / day

Email recipients per day

100* / day

100* / day

1,500* / day

Email read/write (excluding send)

20,000 / day

40,000 / day

50,000 / day

Spreadsheets created

250 / day

500 / day

3,200 / day

Triggers total runtime

90 min / day

3 hr / day

6 hr / day

URL Fetch calls

20,000 / day

50,000 / day

100,000 / day

URL Fetch data received

100MB / day

100MB / day

100MB / day

30 of 40

Feature

Consumer (gmail.com)

Google Apps free edition (legacy)

G Suite Basic/Business/Edu/Gov

Script runtime

6 min / execution

6 min / execution

6 min / execution

Email attachments

250 / msg

250 / msg

250 / msg

Email body size

200kB / msg

200kB / msg

400kB / msg

Email recipients per message

50 / msg

50 / msg

50 / msg

Email total attachments size

25MB / msg

25MB / msg

25MB / msg

URL Fetch headers

100 / call

100 / call

100 / call

URL Fetch header size

8kB / call

8kB / call

8kB / call

URL Fetch POST size

10MB / call

10MB / call

10MB / call

URL Fetch URL length

2kB / call

2kB / call

2kB / call

31 of 40

Let's play…

CC-BY-NC-ND Elke Noda

https://flic.kr/p/58zapN

32 of 40

A simple data collection and email example

33 of 40

Client Side: Making AJAX like call

<script>� function handleFormSubmit(formObject) {� google.script.run.withSuccessHandler(updateUrl)

.processForm(formObject);� }�</script>

​

34 of 40

Server Side: Getting the user’s email

​

​

�� // able to get email of who is using the form � data.engineer = Session.getEffectiveUser().getEmail();

​

​

​

35 of 40

Server Side: Adding a file from a form to Google Drive

// we get our Pics folder� var folder = DriveApp.getFolderById('0B6GkLMU9sHmLejN2R0xUaVJfVjA');� var formBlob = formObject.myPhoto;� // sending image file to our Google Drive folder� var imgFile = folder.createFile(formBlob);

​

​

​

​

36 of 40

Server Side: Writing data to a Google Sheet

// Reading a Google Sheet� var sheet = SpreadsheetApp.openById('1ANtlQPLPpC…vOIqR4wYayWdVZU4')� .getActiveSheet();� // writing the data to the sheet - each row []� var towrite = [formObject.name, … new Date(), imgFile.getUrl()];� // getRange(Integer row, Integer column, Integer numRows, Integer numColumns) : Range� sheet.getRange(row+1, 2, 1, towrite.length).setValues([towrite]);

37 of 40

Server Side: Getting Slides as PDF and emailing as attachment

� // Sending a copy of the cert as pdf� // https://developers.google.com/apps-script/reference/mail/mail-app� MailApp.sendEmail('m.hawksey@gmail.com', 'Attachment example', 'Certificate attached.', {� name: 'Automatic Emailer Script',� attachments: [DECK.getAs(MimeType.PDF)]� });

38 of 40

Server Side: Getting Slides as PDF and emailing as attachment

39 of 40

Community

40 of 40

Thanks!

http://bit.ly/EdMobGAS