Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Google Apps Script the Authentic{ated} Mobile Playground

388 views

Published on

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

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Google Apps Script the Authentic{ated} Mobile Playground

  1. 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
  2. 2. http://bit.ly/EdMobGAS
  3. 3. Google G Suite...
  4. 4. Google Apps Script CC-BY Google – Google Apps Script, 13-03-2012
  5. 5. JavaScript in the cloud Apps Script is based on JavaScript 1.6, plus a few features from 1.7 and 1.8.
  6. 6. Where.. StandaloneSheets DocsForms Sites
  7. 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
  8. 8. Integration CC-BY-NC Eugen Stoll https://flic.kr/p/5c6ce
  9. 9. One liners
  10. 10. One liners
  11. 11. One liners
  12. 12. One liners{ish}
  13. 13. Toast
  14. 14. One liners services Calendar Contacts Document Drive Forms Gmail Groups Language Maps Sites Spreadsheet
  15. 15. 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
  16. 16. Fetch... BY-NC-SA tarteme https://flic.kr/p/bAoEyi
  17. 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.
  18. 18. Identity CC-BY-NC Thomas Hawk https://flic.kr/p/bUy6wK
  19. 19. Google Apps Script Web apps
  20. 20. Google Add-ons CC-BY gail heidel https://flic.kr/p/65aFCx
  21. 21. Customising Sheets, Documents and Forms... Sheets + Add-ons Documents + Add-ons Forms + Add-ons
  22. 22. Domain distribution
  23. 23. Android Add-ons CC-BY gail heidel https://flic.kr/p/65aFCx
  24. 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.
  25. 25. The Android Add-on experience…
  26. 26. Execution API… CC-BY-NC-ND Dizzy Girl https://flic.kr/p/cpvb9
  27. 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.
  28. 28. Limits… CC-BY-NC Chris Campbell https://flic.kr/p/5YdSeh
  29. 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
  30. 30. 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. 31. Let's play… CC-BY-NC-ND Elke Noda https://flic.kr/p/58zapN
  32. 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. 33. Client Side: Making AJAX like call <script> function handleFormSubmit(formObject) { google.script.run.withSuccessHandler(updateUrl) .processForm(formObject); } </script>
  34. 34. Server Side: Getting the user’s email // able to get email of who is using the form data.engineer = Session.getEffectiveUser().getEmail();
  35. 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. 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. 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)] });
  38. 38. Server Side: Getting Slides as PDF and emailing as attachment
  39. 39. Community
  40. 40. Thanks! +MartinHawksey @mhawksey mashe.hawksey.info http://bit.ly/EdMobGAS

×