Presentation given at the Edinburgh Mobile Dev Meetup on 15 Feb 2017 highlighting some features of Google Apps Script which may be of interest to mobile developers. A video recording of the session is available at https://youtu.be/N9WUVzLmaJo?t=39m54s
Breaking the Kubernetes Kill Chain: Host Path Mount
Google Apps Script the Authentic{ated} Mobile Playground
1. This work is licensed under a
Creative Commons
Attribution 4.0 Unported
License. CC-BY mhawksey
Google Apps Script:
+Martin Hawksey
@mhawksey
The authentic{ated} playground
http://bit.ly/EdMobGAS
7. 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
17. “
…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.
24. “
… 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.
27. “
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.
29. 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
32. A simple data collection and email example
● Google Drive Storage Folders
● Google Sheet - Data Source
● Google Slides Template (Used to generate .PDF)
● Source Code
● Deployed Web App
33. Client Side: Making AJAX like call
<script>
function handleFormSubmit(formObject) {
google.script.run.withSuccessHandler(updateUrl)
.processForm(formObject);
}
</script>
34. Server Side: Getting the user’s email
// able to get email of who is using the form
data.engineer = Session.getEffectiveUser().getEmail();
35. 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. 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. 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)]
});