15. Script Services
◉ Base
◉ Cache
◉ Card
◉ Charts
◉ Content
◉ HTML
◉ JDBC
◉ Lock
◉ Mail
◉ Optimization
◉ Properties
◉ Script
◉ URL Fetch
◉ Utilities
◉ XML
16. Type of Scripts - Standalone
// Log the name of every file in the user's Drive that modified after February 28,
// 2013 whose name contains "untitled".
function doAction(){
var files = DriveApp.searchFiles(
'modifiedDate > "2015-01-01" and title contains "untitled"');
while (files.hasNext()) {
var file = files.next();
Logger.log(file.getName());
}
}
Standalone
is any script that is not bound to a Google Sheets, Docs, Slides or Forms file or Google
Sites.
[iOS Taipei - Apps Script - Type of Scripts - Standalone](https://goo.gl/oj8WVO)
17. Type of Scripts - Bound to G Suite Documents
function doAction(range) {
// Get the active spreadsheet and the active sheet
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
// Get the range of cells that store employee data.
var libraryDataRange = sheet.getRange(range);
var libraryObjects = getRowsData(sheet, libraryDataRange, 1);
libraryObjects.forEach(function (row, index) {
var latlng = getLatitudeLongitude(row.address)
if (latlng) {
sheet.getRange(index + 2, 5, 1, 1).setValue(latlng.lat);
sheet.getRange(index + 2, 6, 1, 1).setValue(latlng.lng);
}
});
}
Bound to Google Apps
A script is bound to a Google Sheets, Docs, or Forms file.
18. Type of Scripts - Bound to G Suite Documents. continue
Trigger and Events
Triggers let Apps Script run a function automatically when a certain event,
like opening a document, occurs.
[coffeemap-testing-form - Google Sheets](https://goo.gl/ZAIOtT)
[coffeemap](https://goo.gl/Wb91tW) quick setup form
19. Type of Scripts - Web Apps and Site Gadgets
Web Apps and Site Gadgets
If you build a user interface for a
script, you can publish the script
as a web app
◉ It contains a doGet(e) and
doPost(e) function.
◉ The function returns an
HTML service HtmlOutput
object or a Content service
TextOutput object.
20. Type of Scripts - Web Apps and Site Gadgets. continue
function doGet() {
var ss = SpreadsheetApp.openById('1QgsaX4Vn_lIwLFRC_iHs6gmJYIP4y-35nVqQOpz4B0s');
var sheet = ss.getSheets()[0];
// Get the range of cells that store employee data.
var employeeDataRange = ss.getRangeByName("employeeData");
// For every row of employee data, generate an employee object.
var employeeObjects = getRowsData(sheet, employeeDataRange);
return ContentService.createTextOutput(JSON.stringify(employeeObjects)).setMimeType(ContentService.MimeType.JSON);
}
$ curl -L https://script.google.com/macros/s/AKfycbz4Z2dm-MUidB98H5XbekL0LZnvPVRM3ekpG-NSrScc9tvI87A/exec
[{"level":1,"id":"A00","parent":"root","type":"D","title":"資訊研發
處","email":"A00@aa.bb.cc"},{"level":2,"id":"A10","parent":"A00","type":"D","title":"資訊研發
部","email":"A10@aa.bb.cc"},{"level":3,"id":"SunnyHu","parent":"A10","type":"U","title":"胡適 ...
30. Study info
◉ [Google apps script - simon
su](http://www.slideshare.net/peihsinsu/google-apps-script-24469585)
◉ [entaq/GoogleAppsScript](https://github.com/entaq/GoogleAppsScript)
◉ [Script It! with Android -
YouTube](https://www.youtube.com/watch?v=RSgMEtRl0sw&list=PL68F511F6
E3C122EB)
◉ [Apps Script Crash Course: ContentService
YouTube](https://www.youtube.com/watch?v=JRGzVdliQOQ&list=PL68F511F6
E3C122EB)
◉ [Apps Script | Google Developers](https://developers.google.com/apps-script/)
[Google Apps Script 入門與應用 - 資訊學科中
心](http://icerc.tnssh.tn.edu.tw/download/rs/1030429_3.pdf)
31. Study information - examples
◉ [Generate EPUB file with Google Apps Scripts |
blog.softapalvelin.com](http://blog.softapalvelin.com/2013/02/generate-epub-file-wi
th-google-app.html)
◉ [RSSToEPUB](https://goo.gl/YCDDBo)
[google/google-apps-script-samples](https://github.com/google/google-apps-script-s
amples)
◉ [Tutorials | Apps Script | Google
Developers](https://developers.google.com/apps-script/articles)
◉ [Parsing HTML - Google Apps Script
Examples](https://sites.google.com/site/scriptsexamples/learn-by-example/parsing-
html)
32. Study information - Tools
◉ [danthareja/node-google-apps-script: The easiest way to develop Google Apps Script
projects](https://github.com/danthareja/node-google-apps-script)