View
193
Download
3
Category
Preview:
Citation preview
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
http://bit.ly/EdMobGAS
Google G Suite...
Google Apps Script
CC-BY Google – Google Apps Script, 13-03-2012
JavaScript in the cloud
Apps Script is based on JavaScript 1.6, plus a few features from 1.7 and 1.8.
Where..
StandaloneSheets DocsForms Sites
A brief history
2009
Scripts in SheetsCustom functions
2010
UiApp*Web Apps (run as developer)Script Gallery*
2011
Scripts in SitesGUI Builder*More services
2012
Standalone scriptsHTMLSerivceScriptDb*Web Apps (run as user)Libraries and versioningContent ServiceChrome Web Store
2013
Scripts in DocScripts in FormsAuth flowMore services
2014
Add-on for Documents, Sheets and FormsIFRAME for HTMLService
* Denotes deprecated services/features
Adapted from Wesley Chun’s Google Apps Script
2015
Execution API
2016
Iframe EmbedAndroid Add-ons
Integration
CC-BY-NC Eugen Stollhttps://flic.kr/p/5c6ce
One liners
One liners
One liners{ish}
Toast
One liners services
Calendar
Contacts
Document
Drive
Forms
Gmail
Groups
Language
Maps
Sites
Spreadsheet
One{ish} liners services
AdSense
Analytics
Apps Activity
BigQuery
Calendar
Classroom
Drive
DoubleClick Campaigns
Fusion Tables
Gmail
Google+
Google+ Domains
Mirror
Prediction
Shopping Content
Tasks
URL Shortener
YouTube
Fetch...
BY-NC-SA tartemehttps://flic.kr/p/bAoEyi
“
…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.
Identity
CC-BY-NC Thomas Hawk https://flic.kr/p/bUy6wK
Google Apps Script Web apps
Google Add-ons
CC-BY gail heidelhttps://flic.kr/p/65aFCx
Customising Sheets, Documents and Forms...
Sheets + Add-ons Documents + Add-ons Forms + Add-ons
Domain distribution
Android Add-ons
CC-BY gail heidelhttps://flic.kr/p/65aFCx
“
… 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.
The Android Add-on experience…
Execution API…
CC-BY-NC-ND Dizzy Girlhttps://flic.kr/p/cpvb9
“
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.
Limits…
CC-BY-NC Chris Campbellhttps://flic.kr/p/5YdSeh
FeatureConsumer
(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
FeatureConsumer
(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
Let's play…
CC-BY-NC-ND Elke Nodahttps://flic.kr/p/58zapN
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
Client Side: Making AJAX like call
<script>
function handleFormSubmit(formObject) {
google.script.run.withSuccessHandler(updateUrl)
.processForm(formObject);
}
</script>
Server Side: Getting the user’s email
// able to get email of who is using the form
data.engineer = Session.getEffectiveUser().getEmail();
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);
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]);
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)]
});
Server Side: Getting Slides as PDF and emailing as attachment
Community
Thanks!
+MartinHawksey@mhawksey
mashe.hawksey.info
http://bit.ly/EdMobGAS
Recommended