SlideShare une entreprise Scribd logo
1  sur  44
Télécharger pour lire hors ligne
Google
Apps Script
Introduction
https://www.facebook.com/groups/GCPUG.TW/
https://plus.google.com/u/0/communities/116100913832589966421
Google Cloud Platform User Group Taiwan
我們是Google Cloud Platform Taiwan User Group。在Google雲端服務在台灣地區展露頭角之後,
有許多新的服務、新的知識、新的創意,歡迎大家一起分享,一起了解 Google雲端服務...
GCPUG透過網際網路串聯喜好 Google Cloud的使用者,分享與交流使用 GCP的點滴鑑驗。如果您
是Google Cloud Platform的初學者,您應該來聽聽前輩們的使用經驗;如果您是 Google Cloud
Platform的Expert,您應該來分享一下寶貴的經驗,並與更多高手互相交流;如果您還沒開始用
Google Cloud Platform,那麼您應該馬上來聽聽我們是怎麼使用 Google Cloud的!
Hello!
I am Cage Chung
I am here because I like
to share my
experiences.
You can find me at:
http://kaichu.io
Outline
◎ What’s Google Apps Script?
◎ Case study - Orgtree chrome extension
◎ Google Apps Script for Mobile developers
◎ Tips & Study information
1.
What’s Google App
Scripts
Let’s start with the first set of slides
“
Google Apps Script is a scripting
language based on JavaScript
that lets you do new and cool
things with Google Apps
Where
Google apps, 1 platform in the cloud
Add-ons for Google Apps
Google Sheets, Docs, and Forms
Add-ons run inside Google Sheets, Docs, and Forms
Add-ons for Google Apps - continue
Google Service
◎ Calendar
◎ Contacts
◎ Documents
◎ Domain Deprecated
◎ Drive
◎ Forms
◎ Gmail
◎ Groups
◎ Language
◎ Maps
◎ Sites
◎ Spreadsheet
Advances Google Service
◎ Admin SDK
◎ AdSense
◎ Analytics
◎ App Activity
◎ BigQuery
◎ Calendar
◎ Classroom
◎ Drive
◎ DoubleClick
Campaigns
◎ Fusion Table
◎ Gmail
◎ Google+
◎ Google+ Domains
◎ Mirror
◎ Prediction
◎ Shopping Content
◎ Tasks
◎ URL Shortener
◎ YouTube
Type of Scripts - Standalone
Standalone
is any script that is not bound to a Google Sheets, Docs, or Forms file
or Google Sites.
// 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());
}
}
[iOS Taipei - Apps Script - Type of Scripts - Standalone](https://goo.gl/oj8WVO)
Bound to Google Apps
A script is bound to a Google Sheets, Docs, or Forms file.
Type of Scripts - Bound to Google Apps
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);
}
});
}
Type of Scripts - Bound to Google Apps. continue
[coffeemap-testing-form - Google Sheets](https://goo.gl/ZAIOtT)
[coffeemap](https://goo.gl/Wb91tW) quick setup form
[Coffee Stores Map](https://goo.gl/Wg6mWu)
Trigger and Events
Triggers let Apps Script run a function automatically when a certain
event, like opening a document, occurs.
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.
Type of Scripts - Web Apps and Site Gadgets
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);
}
...
[iOS Taipei - employee Data](https://goo.gl/NpdIrQ)
$ 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":"胡適 ...
2.
Case Study -
Orgtree Chrome
extension
Let’s start with the second set of
slides
Big
concept
Insert your own
organization contacts
to Gmail and Drive with
ease
Place your screenshot here
Orgtree chrome extension - Gmail
Place your screenshot here
Orgtree chrome extension - Drive
Place your screenshot here
Orgtree chrome extension - Pick
Spreadsheet
Orgtree architecture
Google Apps Script Execution API
Orgtree Chrome extension
Spreadsheet
orgtree-example-data
Level ID Parent Type * Title Email
1 A00 root D 資訊研發處 A00@aa.bb.cc
2 A10 A00 D 資訊研發部 A10@aa.bb.cc
3 SunnyHu A10 U 胡適 hushi@aa.bb.cc
3 SimonSu A10 U 蘇武 suwu@aa.bb.cc
2 EthanChang A00 U 張三 zhangshang@aa.bb.cc
1 B00 root D 技術支援處 B00@aa.bb.cc
2 BensonChen B00 U 陳班森 bensonchen@aa.bb.cc
[orgtree - sheet 2 json](https://goo.gl/WmaHmG)
Apps Script
function getSheetJSON(sheetId) {
var ss = SpreadsheetApp.openById(sheetId);
var sheets = ss.getSheets();
var json = sheets.map(function(sheet) {
return convertSheet2JsonText(sheet);
});
return JSON.stringify(json);
}
function convertSheet2JsonText(sheet) {
// read spreadsheet value to array
...
return jsonArray;
}
Apps Script - continue
◎ Files/Project properties/scopes - https://www.
googleapis.com/auth/spreadsheets
◎ Resources/Developers Console Project -
Link Google Console Project
○ Google Apps Script Execution API - Register OAuth
2.0 client IDs required.
Google Apps Script Execution API
/**
* Google apps script ID
*/
const SCRIPTID = 'M6_REvtEnxTdstkFPTpMBrkRmolM6jgKW';
/**
* Google apps script function name
*/
const EXECUTE_FUNCTION = 'getSheetJSON';
fetch(`https://script.googleapis.com/v1/scripts/${CONSTANTS.SCRIPTID}:run`, {
method: 'post',
headers: {
Authorization: 'Bearer ' + oauth.token,
},
body: JSON.stringify({
function: CONSTANTS.EXECUTE_FUNCTION,
parameters: [sheet.id],
devMode: true,
}),
})
.then(response => response.json())
.then(json => dispatch(receiveSheet(sheet, json)));
benefit
◎ No database management
◎ Each user can have their own orgree data in
private spreadsheet (grant oauth)
Demo
fetch specific spreadsheet data via
Google Apps Script Execution API
3.
Google Apps Script
for Mobile
developers
Let’s start with the third set of
slides
employee App
Architecture
Data in spreadsheet
Content Service (JSON)
employee App - outline
◎ Data in Spreadsheet setup
◎ Content Service (JSON) - App Script
◎ iOS - calling restful API (react native)
employee spreadsheet Data
Level ID Parent Type * Title Email
1 A00 root D 資訊研發處 A00@aa.bb.cc
2 A10 A00 D 資訊研發部 A10@aa.bb.cc
3 SunnyHu A10 U 胡適 hushi@aa.bb.cc
3 SimonSu A10 U 蘇武 suwu@aa.bb.cc
2 EthanChang A00 U 張三 zhangshang@aa.bb.cc
1 B00 root D 技術支援處 B00@aa.bb.cc
2 BensonChen B00 U 陳班森 bensonchen@gov.tw
[iOS Taipei - employee Data - Google Sheets](https://goo.
gl/A1Hdqd)
Content Service (JSON) App Script
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);
}
...
Read specific spreadsheet content
and return JSON string
[iOS Taipei - employee Data](https://goo.gl/NpdIrQ)
Content Service (JSON) App Script - continue
Publish/Deploy as web app
Content Service (JSON) App Script - continue
$ 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":"胡適","email":"hushi@aa.bb.cc"},{"level":3,"id":"SimonSu","
parent":"A10","type":"U","title":"蘇武","email":"suwu@aa.bb.cc"},{"level":2,"id":"EthanChang","parent":"
A00","type":"U","title":"張三","email":"zhangshang@aa.bb.cc"},{"level":1,"id":"B00","parent":"root","
type":"D","title":"技術支援處","email":"B00@aa.bb.cc"},{"level":2,"id":"BensonChen","parent":"B00","
type":"U","title":"陳班森","email":"bensonchen@aa.bb.cc"}]
iOS employee App - react native
var React = require('react-native');
var {AppRegistry, StyleSheet, Text, View, ListView, TouchableOpacity, AlertIndicatorIOS,
ActivityIndicatorIOS, AlertIOS} = React;
var SPREADSHEET_WEB_API_URL = 'https://script.google.com/macros/s/AKfycbz4Z2dm-MUidB98H5XbekL0LZnvPVRM3ekpG-
NSrScc9tvI87A/exec';
class AwesomeProject extends React.Component {
...
fetchData () {
fetch(SPREADSHEET_WEB_API_URL).then((response) => response.json()).then((responseData)=>{
let dataBlob = [];
responseData.forEach(item=>{dataBlob.push(`${item.title} - ${item.email}`);});
this.setState({dataSource: this.state.dataSource.cloneWithRows(dataBlob), loaded: true});
}).done();
}
render () {
...
}
}
AppRegistry.registerComponent('AwesomeProject', () => AwesomeProject);
Demo
calling restful service and get JSON
back
Let’s review some concepts
Content Service
Google Apps Script support
ContentService that allows for
data to be served from
Spreadsheet with your logic
Simple backend
store your data in Google
Spreadsheet without build another
database for small project
4.
Tips & Study
information
Let’s start with the fourth set of
slides
“
Google Apps Script function not
found: doGet.
You need to save a new version and publish
the new version to make sure your app gets
updated properly
File -> Manage versions...
[javascript - Google Apps Script function not found: doGet - Stack Overflow](http://goo.gl/CXxAOT)
“
[Script It! with Android - YouTube](https://www.youtube.com/watch?v=RSgMEtRl0sw&list=PL68F511F6E3C122EB)
Study information
◎ [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=PL68F511F6E3C122EB)
○ [Apps Script Crash Course: ContentService - YouTube](https://www.
youtube.com/watch?v=JRGzVdliQOQ&list=PL68F511F6E3C122EB)
◎ [Apps Script | Google Developers](https://developers.google.com/apps-
script/)
◎ [Google Apps Script 入門與應用 - 資訊學科中心](http://icerc.tnssh.tn.edu.
tw/download/rs/1030429_3.pdf)
Study information - examples
◎ [Generate EPUB file with Google Apps Scripts | blog.softapalvelin.com](http:
//blog.softapalvelin.com/2013/02/generate-epub-file-with-google-app.html)
○ [RSSToEPUB](https://goo.gl/YCDDBo)
◎ [google/google-apps-script-samples](https://github.com/google/google-
apps-script-samples)
◎ [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)
Thanks!
Any questions?
You can find me at:
http://kaichu.io
cage.chung@gmail.com

Contenu connexe

Tendances

Web Application Introduction
Web Application  IntroductionWeb Application  Introduction
Web Application Introductionshaojung
 
Introduction to Web Programming - first course
Introduction to Web Programming - first courseIntroduction to Web Programming - first course
Introduction to Web Programming - first courseVlad Posea
 
Preparing for GA4 - The Future of Google Analytics
Preparing for GA4 - The Future of Google AnalyticsPreparing for GA4 - The Future of Google Analytics
Preparing for GA4 - The Future of Google AnalyticsJason Dodge
 
How to Know Exactly Where to Optimize with GA4.pptx
How to Know Exactly Where to Optimize with GA4.pptxHow to Know Exactly Where to Optimize with GA4.pptx
How to Know Exactly Where to Optimize with GA4.pptxMeasurementMarketing.io
 
Google Tag Manager Training
Google Tag Manager TrainingGoogle Tag Manager Training
Google Tag Manager TrainingEmpirical Path
 
Design Pattern - Singleton Pattern
Design Pattern - Singleton PatternDesign Pattern - Singleton Pattern
Design Pattern - Singleton PatternMudasir Qazi
 
Intelligent web crawling
Intelligent web crawlingIntelligent web crawling
Intelligent web crawlingDenis Shestakov
 
SE_Lec 05_System Modelling and Context Model
SE_Lec 05_System Modelling and Context ModelSE_Lec 05_System Modelling and Context Model
SE_Lec 05_System Modelling and Context ModelAmr E. Mohamed
 
Wampserver installation ajay-di-sharma
Wampserver installation ajay-di-sharmaWampserver installation ajay-di-sharma
Wampserver installation ajay-di-sharmaAjay Di Sharma
 

Tendances (20)

jQuery
jQueryjQuery
jQuery
 
Web Application Introduction
Web Application  IntroductionWeb Application  Introduction
Web Application Introduction
 
Bootstrap 5 ppt
Bootstrap 5 pptBootstrap 5 ppt
Bootstrap 5 ppt
 
Introduction to Web Programming - first course
Introduction to Web Programming - first courseIntroduction to Web Programming - first course
Introduction to Web Programming - first course
 
Laravel Eloquent ORM
Laravel Eloquent ORMLaravel Eloquent ORM
Laravel Eloquent ORM
 
Bootstrap ppt
Bootstrap pptBootstrap ppt
Bootstrap ppt
 
4b use-case analysis
4b use-case analysis4b use-case analysis
4b use-case analysis
 
Preparing for GA4 - The Future of Google Analytics
Preparing for GA4 - The Future of Google AnalyticsPreparing for GA4 - The Future of Google Analytics
Preparing for GA4 - The Future of Google Analytics
 
How to Know Exactly Where to Optimize with GA4.pptx
How to Know Exactly Where to Optimize with GA4.pptxHow to Know Exactly Where to Optimize with GA4.pptx
How to Know Exactly Where to Optimize with GA4.pptx
 
Bootstrap 5 basic
Bootstrap 5 basicBootstrap 5 basic
Bootstrap 5 basic
 
Google Tag Manager Training
Google Tag Manager TrainingGoogle Tag Manager Training
Google Tag Manager Training
 
Design Pattern - Singleton Pattern
Design Pattern - Singleton PatternDesign Pattern - Singleton Pattern
Design Pattern - Singleton Pattern
 
Intelligent web crawling
Intelligent web crawlingIntelligent web crawling
Intelligent web crawling
 
CS8651 IP Unit 3.pptx
CS8651 IP Unit 3.pptxCS8651 IP Unit 3.pptx
CS8651 IP Unit 3.pptx
 
Trello
TrelloTrello
Trello
 
Introduction to Google App Engine
Introduction to Google App EngineIntroduction to Google App Engine
Introduction to Google App Engine
 
SE_Lec 05_System Modelling and Context Model
SE_Lec 05_System Modelling and Context ModelSE_Lec 05_System Modelling and Context Model
SE_Lec 05_System Modelling and Context Model
 
XML
XMLXML
XML
 
Heat map
Heat mapHeat map
Heat map
 
Wampserver installation ajay-di-sharma
Wampserver installation ajay-di-sharmaWampserver installation ajay-di-sharma
Wampserver installation ajay-di-sharma
 

En vedette

Continuous Integration & Continuous Delivery with GCP
Continuous Integration & Continuous Delivery with GCPContinuous Integration & Continuous Delivery with GCP
Continuous Integration & Continuous Delivery with GCPKAI CHU CHUNG
 
Nas 也可以揀土豆
Nas 也可以揀土豆Nas 也可以揀土豆
Nas 也可以揀土豆KAI CHU CHUNG
 
痞客趴趴走 Waldo
痞客趴趴走   Waldo痞客趴趴走   Waldo
痞客趴趴走 WaldoKAI CHU CHUNG
 
Gae managed vm introduction
Gae managed vm introductionGae managed vm introduction
Gae managed vm introductionKAI CHU CHUNG
 
Google app engine (gae) 演進史
Google app engine (gae) 演進史Google app engine (gae) 演進史
Google app engine (gae) 演進史KAI CHU CHUNG
 
Django oscar introduction
Django oscar introductionDjango oscar introduction
Django oscar introductionKAI CHU CHUNG
 
Introduction to chrome extension development
Introduction to chrome extension developmentIntroduction to chrome extension development
Introduction to chrome extension developmentKAI CHU CHUNG
 
Screenshot as a service
Screenshot as a serviceScreenshot as a service
Screenshot as a serviceKAI CHU CHUNG
 
Google apps script introduction
Google apps script introductionGoogle apps script introduction
Google apps script introductionKAI CHU CHUNG
 
60分鐘完送百萬edm,背後雲端ci/cd實戰大公開
60分鐘完送百萬edm,背後雲端ci/cd實戰大公開60分鐘完送百萬edm,背後雲端ci/cd實戰大公開
60分鐘完送百萬edm,背後雲端ci/cd實戰大公開KAI CHU CHUNG
 

En vedette (11)

Continuous Integration & Continuous Delivery with GCP
Continuous Integration & Continuous Delivery with GCPContinuous Integration & Continuous Delivery with GCP
Continuous Integration & Continuous Delivery with GCP
 
Nas 也可以揀土豆
Nas 也可以揀土豆Nas 也可以揀土豆
Nas 也可以揀土豆
 
Waldo-gcp
Waldo-gcpWaldo-gcp
Waldo-gcp
 
痞客趴趴走 Waldo
痞客趴趴走   Waldo痞客趴趴走   Waldo
痞客趴趴走 Waldo
 
Gae managed vm introduction
Gae managed vm introductionGae managed vm introduction
Gae managed vm introduction
 
Google app engine (gae) 演進史
Google app engine (gae) 演進史Google app engine (gae) 演進史
Google app engine (gae) 演進史
 
Django oscar introduction
Django oscar introductionDjango oscar introduction
Django oscar introduction
 
Introduction to chrome extension development
Introduction to chrome extension developmentIntroduction to chrome extension development
Introduction to chrome extension development
 
Screenshot as a service
Screenshot as a serviceScreenshot as a service
Screenshot as a service
 
Google apps script introduction
Google apps script introductionGoogle apps script introduction
Google apps script introduction
 
60分鐘完送百萬edm,背後雲端ci/cd實戰大公開
60分鐘完送百萬edm,背後雲端ci/cd實戰大公開60分鐘完送百萬edm,背後雲端ci/cd實戰大公開
60分鐘完送百萬edm,背後雲端ci/cd實戰大公開
 

Similaire à Google apps script introduction

Google Cloud @ Hackathons (2020)
Google Cloud @ Hackathons (2020)Google Cloud @ Hackathons (2020)
Google Cloud @ Hackathons (2020)wesley chun
 
Google Cloud lightning talk @MHacks
Google Cloud lightning talk @MHacksGoogle Cloud lightning talk @MHacks
Google Cloud lightning talk @MHackswesley chun
 
Cloud computing overview & running your code on Google Cloud
Cloud computing overview & running your code on Google CloudCloud computing overview & running your code on Google Cloud
Cloud computing overview & running your code on Google Cloudwesley chun
 
The Big Picture and How to Get Started
The Big Picture and How to Get StartedThe Big Picture and How to Get Started
The Big Picture and How to Get Startedguest1af57e
 
JBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
JBUG 11 - Django-The Web Framework For Perfectionists With DeadlinesJBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
JBUG 11 - Django-The Web Framework For Perfectionists With DeadlinesTikal Knowledge
 
Google: Drive, Documents and Apps Script - How to work efficiently and happily
Google:  Drive, Documents  and Apps Script - How to work efficiently and happilyGoogle:  Drive, Documents  and Apps Script - How to work efficiently and happily
Google: Drive, Documents and Apps Script - How to work efficiently and happilyAlessandra Santi
 
Using Google (Cloud) APIs
Using Google (Cloud) APIsUsing Google (Cloud) APIs
Using Google (Cloud) APIswesley chun
 
Automation in seo. Tools and tricks
Automation in seo. Tools and tricksAutomation in seo. Tools and tricks
Automation in seo. Tools and tricksNetpeakBG
 
Automation in seo. Tools and tricks
Automation in seo. Tools and tricksAutomation in seo. Tools and tricks
Automation in seo. Tools and tricksNetpeak
 
Art & music vs Google App Engine
Art & music vs Google App EngineArt & music vs Google App Engine
Art & music vs Google App Enginethomas alisi
 
The Web on OSGi: Here's How
The Web on OSGi: Here's HowThe Web on OSGi: Here's How
The Web on OSGi: Here's Howmrdon
 
Google Apps Script: Accessing G Suite & other Google services with JavaScript
Google Apps Script: Accessing G Suite & other Google services with JavaScriptGoogle Apps Script: Accessing G Suite & other Google services with JavaScript
Google Apps Script: Accessing G Suite & other Google services with JavaScriptwesley chun
 
How to build unified Batch & Streaming Pipelines with Apache Beam and Dataflow
How to build unified Batch & Streaming Pipelines with Apache Beam and DataflowHow to build unified Batch & Streaming Pipelines with Apache Beam and Dataflow
How to build unified Batch & Streaming Pipelines with Apache Beam and DataflowDaniel Zivkovic
 
Cloud computing overview & running your code on Google Cloud (Jun 2019)
Cloud computing overview & running your code on Google Cloud (Jun 2019)Cloud computing overview & running your code on Google Cloud (Jun 2019)
Cloud computing overview & running your code on Google Cloud (Jun 2019)wesley chun
 
Powerful Google Cloud tools for your hack (2020)
Powerful Google Cloud tools for your hack (2020)Powerful Google Cloud tools for your hack (2020)
Powerful Google Cloud tools for your hack (2020)wesley chun
 
Advanced query parsing techniques
Advanced query parsing techniquesAdvanced query parsing techniques
Advanced query parsing techniqueslucenerevolution
 

Similaire à Google apps script introduction (20)

Google Cloud @ Hackathons (2020)
Google Cloud @ Hackathons (2020)Google Cloud @ Hackathons (2020)
Google Cloud @ Hackathons (2020)
 
Google Cloud lightning talk @MHacks
Google Cloud lightning talk @MHacksGoogle Cloud lightning talk @MHacks
Google Cloud lightning talk @MHacks
 
Data Science on Google Cloud Platform
Data Science on Google Cloud PlatformData Science on Google Cloud Platform
Data Science on Google Cloud Platform
 
Cloud computing overview & running your code on Google Cloud
Cloud computing overview & running your code on Google CloudCloud computing overview & running your code on Google Cloud
Cloud computing overview & running your code on Google Cloud
 
The Big Picture and How to Get Started
The Big Picture and How to Get StartedThe Big Picture and How to Get Started
The Big Picture and How to Get Started
 
JBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
JBUG 11 - Django-The Web Framework For Perfectionists With DeadlinesJBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
JBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
 
Google: Drive, Documents and Apps Script - How to work efficiently and happily
Google:  Drive, Documents  and Apps Script - How to work efficiently and happilyGoogle:  Drive, Documents  and Apps Script - How to work efficiently and happily
Google: Drive, Documents and Apps Script - How to work efficiently and happily
 
Using Google (Cloud) APIs
Using Google (Cloud) APIsUsing Google (Cloud) APIs
Using Google (Cloud) APIs
 
Automation in seo. Tools and tricks
Automation in seo. Tools and tricksAutomation in seo. Tools and tricks
Automation in seo. Tools and tricks
 
Automation in seo. Tools and tricks
Automation in seo. Tools and tricksAutomation in seo. Tools and tricks
Automation in seo. Tools and tricks
 
Art & music vs Google App Engine
Art & music vs Google App EngineArt & music vs Google App Engine
Art & music vs Google App Engine
 
The Web on OSGi: Here's How
The Web on OSGi: Here's HowThe Web on OSGi: Here's How
The Web on OSGi: Here's How
 
Google Apps Script: Accessing G Suite & other Google services with JavaScript
Google Apps Script: Accessing G Suite & other Google services with JavaScriptGoogle Apps Script: Accessing G Suite & other Google services with JavaScript
Google Apps Script: Accessing G Suite & other Google services with JavaScript
 
Google Cloud Platform
Google Cloud Platform Google Cloud Platform
Google Cloud Platform
 
How to build unified Batch & Streaming Pipelines with Apache Beam and Dataflow
How to build unified Batch & Streaming Pipelines with Apache Beam and DataflowHow to build unified Batch & Streaming Pipelines with Apache Beam and Dataflow
How to build unified Batch & Streaming Pipelines with Apache Beam and Dataflow
 
Google Big Query UDFs
Google Big Query UDFsGoogle Big Query UDFs
Google Big Query UDFs
 
Cloud computing overview & running your code on Google Cloud (Jun 2019)
Cloud computing overview & running your code on Google Cloud (Jun 2019)Cloud computing overview & running your code on Google Cloud (Jun 2019)
Cloud computing overview & running your code on Google Cloud (Jun 2019)
 
Powerful Google Cloud tools for your hack (2020)
Powerful Google Cloud tools for your hack (2020)Powerful Google Cloud tools for your hack (2020)
Powerful Google Cloud tools for your hack (2020)
 
Advanced Relevancy Ranking
Advanced Relevancy RankingAdvanced Relevancy Ranking
Advanced Relevancy Ranking
 
Advanced query parsing techniques
Advanced query parsing techniquesAdvanced query parsing techniques
Advanced query parsing techniques
 

Plus de KAI CHU CHUNG

Devfest 2023 - Service Weaver Introduction - Taipei.pdf
Devfest 2023 - Service Weaver Introduction - Taipei.pdfDevfest 2023 - Service Weaver Introduction - Taipei.pdf
Devfest 2023 - Service Weaver Introduction - Taipei.pdfKAI CHU CHUNG
 
DevFest 2022 - Skaffold 2 Deep Dive Taipei.pdf
DevFest 2022 - Skaffold 2 Deep Dive Taipei.pdfDevFest 2022 - Skaffold 2 Deep Dive Taipei.pdf
DevFest 2022 - Skaffold 2 Deep Dive Taipei.pdfKAI CHU CHUNG
 
DevFest 2022 - Cloud Workstation Introduction TaiChung
DevFest 2022 - Cloud Workstation Introduction TaiChungDevFest 2022 - Cloud Workstation Introduction TaiChung
DevFest 2022 - Cloud Workstation Introduction TaiChungKAI CHU CHUNG
 
Devfest 2021' - Artifact Registry Introduction (Taipei)
Devfest 2021' - Artifact Registry Introduction (Taipei)Devfest 2021' - Artifact Registry Introduction (Taipei)
Devfest 2021' - Artifact Registry Introduction (Taipei)KAI CHU CHUNG
 
Coscup x ruby conf tw 2021 google cloud buildpacks 剖析與實踐
Coscup x ruby conf tw 2021  google cloud buildpacks 剖析與實踐Coscup x ruby conf tw 2021  google cloud buildpacks 剖析與實踐
Coscup x ruby conf tw 2021 google cloud buildpacks 剖析與實踐KAI CHU CHUNG
 
Velero search & practice 20210609
Velero search & practice 20210609Velero search & practice 20210609
Velero search & practice 20210609KAI CHU CHUNG
 
Gdg cloud taipei ddt meetup #53 buildpack
Gdg cloud taipei ddt meetup #53 buildpackGdg cloud taipei ddt meetup #53 buildpack
Gdg cloud taipei ddt meetup #53 buildpackKAI CHU CHUNG
 
GDG Cloud Taipei: Meetup #52 - Istio Security: API Authorization
GDG Cloud Taipei: Meetup #52 - Istio Security: API AuthorizationGDG Cloud Taipei: Meetup #52 - Istio Security: API Authorization
GDG Cloud Taipei: Meetup #52 - Istio Security: API AuthorizationKAI CHU CHUNG
 
如何透過 Go-kit 快速搭建微服務架構應用程式實戰
如何透過 Go-kit 快速搭建微服務架構應用程式實戰如何透過 Go-kit 快速搭建微服務架構應用程式實戰
如何透過 Go-kit 快速搭建微服務架構應用程式實戰KAI CHU CHUNG
 
Dev fest 2020 taiwan how to debug microservices on kubernetes as a pros (ht...
Dev fest 2020 taiwan   how to debug microservices on kubernetes as a pros (ht...Dev fest 2020 taiwan   how to debug microservices on kubernetes as a pros (ht...
Dev fest 2020 taiwan how to debug microservices on kubernetes as a pros (ht...KAI CHU CHUNG
 
Google App Engine: Basic
Google App Engine: BasicGoogle App Engine: Basic
Google App Engine: BasicKAI CHU CHUNG
 
COSCUP 2020 Google 技術 x 公共參與 x 開源 口罩地圖技術開源
COSCUP 2020 Google 技術 x 公共參與 x 開源 口罩地圖技術開源COSCUP 2020 Google 技術 x 公共參與 x 開源 口罩地圖技術開源
COSCUP 2020 Google 技術 x 公共參與 x 開源 口罩地圖技術開源KAI CHU CHUNG
 
GDG Cloud Taipei meetup #50 - Build go kit microservices at kubernetes with ...
GDG Cloud Taipei meetup #50 - Build go kit microservices at kubernetes  with ...GDG Cloud Taipei meetup #50 - Build go kit microservices at kubernetes  with ...
GDG Cloud Taipei meetup #50 - Build go kit microservices at kubernetes with ...KAI CHU CHUNG
 
GDG Devfest 2019 - Build go kit microservices at kubernetes with ease
GDG Devfest 2019 - Build go kit microservices at kubernetes with easeGDG Devfest 2019 - Build go kit microservices at kubernetes with ease
GDG Devfest 2019 - Build go kit microservices at kubernetes with easeKAI CHU CHUNG
 
Global GDG Leaders Summit, Google I/O 2018 經驗分享
Global GDG Leaders Summit, Google I/O 2018 經驗分享Global GDG Leaders Summit, Google I/O 2018 經驗分享
Global GDG Leaders Summit, Google I/O 2018 經驗分享KAI CHU CHUNG
 

Plus de KAI CHU CHUNG (15)

Devfest 2023 - Service Weaver Introduction - Taipei.pdf
Devfest 2023 - Service Weaver Introduction - Taipei.pdfDevfest 2023 - Service Weaver Introduction - Taipei.pdf
Devfest 2023 - Service Weaver Introduction - Taipei.pdf
 
DevFest 2022 - Skaffold 2 Deep Dive Taipei.pdf
DevFest 2022 - Skaffold 2 Deep Dive Taipei.pdfDevFest 2022 - Skaffold 2 Deep Dive Taipei.pdf
DevFest 2022 - Skaffold 2 Deep Dive Taipei.pdf
 
DevFest 2022 - Cloud Workstation Introduction TaiChung
DevFest 2022 - Cloud Workstation Introduction TaiChungDevFest 2022 - Cloud Workstation Introduction TaiChung
DevFest 2022 - Cloud Workstation Introduction TaiChung
 
Devfest 2021' - Artifact Registry Introduction (Taipei)
Devfest 2021' - Artifact Registry Introduction (Taipei)Devfest 2021' - Artifact Registry Introduction (Taipei)
Devfest 2021' - Artifact Registry Introduction (Taipei)
 
Coscup x ruby conf tw 2021 google cloud buildpacks 剖析與實踐
Coscup x ruby conf tw 2021  google cloud buildpacks 剖析與實踐Coscup x ruby conf tw 2021  google cloud buildpacks 剖析與實踐
Coscup x ruby conf tw 2021 google cloud buildpacks 剖析與實踐
 
Velero search & practice 20210609
Velero search & practice 20210609Velero search & practice 20210609
Velero search & practice 20210609
 
Gdg cloud taipei ddt meetup #53 buildpack
Gdg cloud taipei ddt meetup #53 buildpackGdg cloud taipei ddt meetup #53 buildpack
Gdg cloud taipei ddt meetup #53 buildpack
 
GDG Cloud Taipei: Meetup #52 - Istio Security: API Authorization
GDG Cloud Taipei: Meetup #52 - Istio Security: API AuthorizationGDG Cloud Taipei: Meetup #52 - Istio Security: API Authorization
GDG Cloud Taipei: Meetup #52 - Istio Security: API Authorization
 
如何透過 Go-kit 快速搭建微服務架構應用程式實戰
如何透過 Go-kit 快速搭建微服務架構應用程式實戰如何透過 Go-kit 快速搭建微服務架構應用程式實戰
如何透過 Go-kit 快速搭建微服務架構應用程式實戰
 
Dev fest 2020 taiwan how to debug microservices on kubernetes as a pros (ht...
Dev fest 2020 taiwan   how to debug microservices on kubernetes as a pros (ht...Dev fest 2020 taiwan   how to debug microservices on kubernetes as a pros (ht...
Dev fest 2020 taiwan how to debug microservices on kubernetes as a pros (ht...
 
Google App Engine: Basic
Google App Engine: BasicGoogle App Engine: Basic
Google App Engine: Basic
 
COSCUP 2020 Google 技術 x 公共參與 x 開源 口罩地圖技術開源
COSCUP 2020 Google 技術 x 公共參與 x 開源 口罩地圖技術開源COSCUP 2020 Google 技術 x 公共參與 x 開源 口罩地圖技術開源
COSCUP 2020 Google 技術 x 公共參與 x 開源 口罩地圖技術開源
 
GDG Cloud Taipei meetup #50 - Build go kit microservices at kubernetes with ...
GDG Cloud Taipei meetup #50 - Build go kit microservices at kubernetes  with ...GDG Cloud Taipei meetup #50 - Build go kit microservices at kubernetes  with ...
GDG Cloud Taipei meetup #50 - Build go kit microservices at kubernetes with ...
 
GDG Devfest 2019 - Build go kit microservices at kubernetes with ease
GDG Devfest 2019 - Build go kit microservices at kubernetes with easeGDG Devfest 2019 - Build go kit microservices at kubernetes with ease
GDG Devfest 2019 - Build go kit microservices at kubernetes with ease
 
Global GDG Leaders Summit, Google I/O 2018 經驗分享
Global GDG Leaders Summit, Google I/O 2018 經驗分享Global GDG Leaders Summit, Google I/O 2018 經驗分享
Global GDG Leaders Summit, Google I/O 2018 經驗分享
 

Dernier

Company Snapshot Theme for Business by Slidesgo.pptx
Company Snapshot Theme for Business by Slidesgo.pptxCompany Snapshot Theme for Business by Slidesgo.pptx
Company Snapshot Theme for Business by Slidesgo.pptxMario
 
ETHICAL HACKING dddddddddddddddfnandni.pptx
ETHICAL HACKING dddddddddddddddfnandni.pptxETHICAL HACKING dddddddddddddddfnandni.pptx
ETHICAL HACKING dddddddddddddddfnandni.pptxNIMMANAGANTI RAMAKRISHNA
 
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书rnrncn29
 
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书rnrncn29
 
Unidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptxUnidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptxmibuzondetrabajo
 
SCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is prediSCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is predieusebiomeyer
 
Top 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxTop 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxDyna Gilbert
 
IP addressing and IPv6, presented by Paul Wilson at IETF 119
IP addressing and IPv6, presented by Paul Wilson at IETF 119IP addressing and IPv6, presented by Paul Wilson at IETF 119
IP addressing and IPv6, presented by Paul Wilson at IETF 119APNIC
 
Film cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasaFilm cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasa494f574xmv
 
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书zdzoqco
 
TRENDS Enabling and inhibiting dimensions.pptx
TRENDS Enabling and inhibiting dimensions.pptxTRENDS Enabling and inhibiting dimensions.pptx
TRENDS Enabling and inhibiting dimensions.pptxAndrieCagasanAkio
 

Dernier (11)

Company Snapshot Theme for Business by Slidesgo.pptx
Company Snapshot Theme for Business by Slidesgo.pptxCompany Snapshot Theme for Business by Slidesgo.pptx
Company Snapshot Theme for Business by Slidesgo.pptx
 
ETHICAL HACKING dddddddddddddddfnandni.pptx
ETHICAL HACKING dddddddddddddddfnandni.pptxETHICAL HACKING dddddddddddddddfnandni.pptx
ETHICAL HACKING dddddddddddddddfnandni.pptx
 
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
 
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
 
Unidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptxUnidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptx
 
SCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is prediSCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is predi
 
Top 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxTop 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptx
 
IP addressing and IPv6, presented by Paul Wilson at IETF 119
IP addressing and IPv6, presented by Paul Wilson at IETF 119IP addressing and IPv6, presented by Paul Wilson at IETF 119
IP addressing and IPv6, presented by Paul Wilson at IETF 119
 
Film cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasaFilm cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasa
 
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
 
TRENDS Enabling and inhibiting dimensions.pptx
TRENDS Enabling and inhibiting dimensions.pptxTRENDS Enabling and inhibiting dimensions.pptx
TRENDS Enabling and inhibiting dimensions.pptx
 

Google apps script introduction

  • 2. https://www.facebook.com/groups/GCPUG.TW/ https://plus.google.com/u/0/communities/116100913832589966421 Google Cloud Platform User Group Taiwan 我們是Google Cloud Platform Taiwan User Group。在Google雲端服務在台灣地區展露頭角之後, 有許多新的服務、新的知識、新的創意,歡迎大家一起分享,一起了解 Google雲端服務... GCPUG透過網際網路串聯喜好 Google Cloud的使用者,分享與交流使用 GCP的點滴鑑驗。如果您 是Google Cloud Platform的初學者,您應該來聽聽前輩們的使用經驗;如果您是 Google Cloud Platform的Expert,您應該來分享一下寶貴的經驗,並與更多高手互相交流;如果您還沒開始用 Google Cloud Platform,那麼您應該馬上來聽聽我們是怎麼使用 Google Cloud的!
  • 3. Hello! I am Cage Chung I am here because I like to share my experiences. You can find me at: http://kaichu.io
  • 4. Outline ◎ What’s Google Apps Script? ◎ Case study - Orgtree chrome extension ◎ Google Apps Script for Mobile developers ◎ Tips & Study information
  • 5. 1. What’s Google App Scripts Let’s start with the first set of slides
  • 6. “ Google Apps Script is a scripting language based on JavaScript that lets you do new and cool things with Google Apps
  • 7. Where Google apps, 1 platform in the cloud
  • 8. Add-ons for Google Apps Google Sheets, Docs, and Forms Add-ons run inside Google Sheets, Docs, and Forms
  • 9. Add-ons for Google Apps - continue
  • 10. Google Service ◎ Calendar ◎ Contacts ◎ Documents ◎ Domain Deprecated ◎ Drive ◎ Forms ◎ Gmail ◎ Groups ◎ Language ◎ Maps ◎ Sites ◎ Spreadsheet
  • 11. Advances Google Service ◎ Admin SDK ◎ AdSense ◎ Analytics ◎ App Activity ◎ BigQuery ◎ Calendar ◎ Classroom ◎ Drive ◎ DoubleClick Campaigns ◎ Fusion Table ◎ Gmail ◎ Google+ ◎ Google+ Domains ◎ Mirror ◎ Prediction ◎ Shopping Content ◎ Tasks ◎ URL Shortener ◎ YouTube
  • 12. Type of Scripts - Standalone Standalone is any script that is not bound to a Google Sheets, Docs, or Forms file or Google Sites. // 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()); } } [iOS Taipei - Apps Script - Type of Scripts - Standalone](https://goo.gl/oj8WVO)
  • 13. Bound to Google Apps A script is bound to a Google Sheets, Docs, or Forms file. Type of Scripts - Bound to Google Apps 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); } }); }
  • 14. Type of Scripts - Bound to Google Apps. continue [coffeemap-testing-form - Google Sheets](https://goo.gl/ZAIOtT) [coffeemap](https://goo.gl/Wb91tW) quick setup form [Coffee Stores Map](https://goo.gl/Wg6mWu) Trigger and Events Triggers let Apps Script run a function automatically when a certain event, like opening a document, occurs.
  • 15. 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. Type of Scripts - Web Apps and Site Gadgets
  • 16. 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); } ... [iOS Taipei - employee Data](https://goo.gl/NpdIrQ) $ 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":"胡適 ...
  • 17. 2. Case Study - Orgtree Chrome extension Let’s start with the second set of slides
  • 18. Big concept Insert your own organization contacts to Gmail and Drive with ease
  • 19. Place your screenshot here Orgtree chrome extension - Gmail
  • 20. Place your screenshot here Orgtree chrome extension - Drive
  • 21. Place your screenshot here Orgtree chrome extension - Pick Spreadsheet
  • 22. Orgtree architecture Google Apps Script Execution API Orgtree Chrome extension Spreadsheet
  • 23. orgtree-example-data Level ID Parent Type * Title Email 1 A00 root D 資訊研發處 A00@aa.bb.cc 2 A10 A00 D 資訊研發部 A10@aa.bb.cc 3 SunnyHu A10 U 胡適 hushi@aa.bb.cc 3 SimonSu A10 U 蘇武 suwu@aa.bb.cc 2 EthanChang A00 U 張三 zhangshang@aa.bb.cc 1 B00 root D 技術支援處 B00@aa.bb.cc 2 BensonChen B00 U 陳班森 bensonchen@aa.bb.cc [orgtree - sheet 2 json](https://goo.gl/WmaHmG)
  • 24. Apps Script function getSheetJSON(sheetId) { var ss = SpreadsheetApp.openById(sheetId); var sheets = ss.getSheets(); var json = sheets.map(function(sheet) { return convertSheet2JsonText(sheet); }); return JSON.stringify(json); } function convertSheet2JsonText(sheet) { // read spreadsheet value to array ... return jsonArray; }
  • 25. Apps Script - continue ◎ Files/Project properties/scopes - https://www. googleapis.com/auth/spreadsheets ◎ Resources/Developers Console Project - Link Google Console Project ○ Google Apps Script Execution API - Register OAuth 2.0 client IDs required.
  • 26. Google Apps Script Execution API /** * Google apps script ID */ const SCRIPTID = 'M6_REvtEnxTdstkFPTpMBrkRmolM6jgKW'; /** * Google apps script function name */ const EXECUTE_FUNCTION = 'getSheetJSON'; fetch(`https://script.googleapis.com/v1/scripts/${CONSTANTS.SCRIPTID}:run`, { method: 'post', headers: { Authorization: 'Bearer ' + oauth.token, }, body: JSON.stringify({ function: CONSTANTS.EXECUTE_FUNCTION, parameters: [sheet.id], devMode: true, }), }) .then(response => response.json()) .then(json => dispatch(receiveSheet(sheet, json)));
  • 27. benefit ◎ No database management ◎ Each user can have their own orgree data in private spreadsheet (grant oauth)
  • 28. Demo fetch specific spreadsheet data via Google Apps Script Execution API
  • 29. 3. Google Apps Script for Mobile developers Let’s start with the third set of slides
  • 30. employee App Architecture Data in spreadsheet Content Service (JSON)
  • 31. employee App - outline ◎ Data in Spreadsheet setup ◎ Content Service (JSON) - App Script ◎ iOS - calling restful API (react native)
  • 32. employee spreadsheet Data Level ID Parent Type * Title Email 1 A00 root D 資訊研發處 A00@aa.bb.cc 2 A10 A00 D 資訊研發部 A10@aa.bb.cc 3 SunnyHu A10 U 胡適 hushi@aa.bb.cc 3 SimonSu A10 U 蘇武 suwu@aa.bb.cc 2 EthanChang A00 U 張三 zhangshang@aa.bb.cc 1 B00 root D 技術支援處 B00@aa.bb.cc 2 BensonChen B00 U 陳班森 bensonchen@gov.tw [iOS Taipei - employee Data - Google Sheets](https://goo. gl/A1Hdqd)
  • 33. Content Service (JSON) App Script 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); } ... Read specific spreadsheet content and return JSON string [iOS Taipei - employee Data](https://goo.gl/NpdIrQ)
  • 34. Content Service (JSON) App Script - continue Publish/Deploy as web app
  • 35. Content Service (JSON) App Script - continue $ 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":"胡適","email":"hushi@aa.bb.cc"},{"level":3,"id":"SimonSu"," parent":"A10","type":"U","title":"蘇武","email":"suwu@aa.bb.cc"},{"level":2,"id":"EthanChang","parent":" A00","type":"U","title":"張三","email":"zhangshang@aa.bb.cc"},{"level":1,"id":"B00","parent":"root"," type":"D","title":"技術支援處","email":"B00@aa.bb.cc"},{"level":2,"id":"BensonChen","parent":"B00"," type":"U","title":"陳班森","email":"bensonchen@aa.bb.cc"}]
  • 36. iOS employee App - react native var React = require('react-native'); var {AppRegistry, StyleSheet, Text, View, ListView, TouchableOpacity, AlertIndicatorIOS, ActivityIndicatorIOS, AlertIOS} = React; var SPREADSHEET_WEB_API_URL = 'https://script.google.com/macros/s/AKfycbz4Z2dm-MUidB98H5XbekL0LZnvPVRM3ekpG- NSrScc9tvI87A/exec'; class AwesomeProject extends React.Component { ... fetchData () { fetch(SPREADSHEET_WEB_API_URL).then((response) => response.json()).then((responseData)=>{ let dataBlob = []; responseData.forEach(item=>{dataBlob.push(`${item.title} - ${item.email}`);}); this.setState({dataSource: this.state.dataSource.cloneWithRows(dataBlob), loaded: true}); }).done(); } render () { ... } } AppRegistry.registerComponent('AwesomeProject', () => AwesomeProject);
  • 37. Demo calling restful service and get JSON back
  • 38. Let’s review some concepts Content Service Google Apps Script support ContentService that allows for data to be served from Spreadsheet with your logic Simple backend store your data in Google Spreadsheet without build another database for small project
  • 39. 4. Tips & Study information Let’s start with the fourth set of slides
  • 40. “ Google Apps Script function not found: doGet. You need to save a new version and publish the new version to make sure your app gets updated properly File -> Manage versions... [javascript - Google Apps Script function not found: doGet - Stack Overflow](http://goo.gl/CXxAOT)
  • 41. “ [Script It! with Android - YouTube](https://www.youtube.com/watch?v=RSgMEtRl0sw&list=PL68F511F6E3C122EB)
  • 42. Study information ◎ [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=PL68F511F6E3C122EB) ○ [Apps Script Crash Course: ContentService - YouTube](https://www. youtube.com/watch?v=JRGzVdliQOQ&list=PL68F511F6E3C122EB) ◎ [Apps Script | Google Developers](https://developers.google.com/apps- script/) ◎ [Google Apps Script 入門與應用 - 資訊學科中心](http://icerc.tnssh.tn.edu. tw/download/rs/1030429_3.pdf)
  • 43. Study information - examples ◎ [Generate EPUB file with Google Apps Scripts | blog.softapalvelin.com](http: //blog.softapalvelin.com/2013/02/generate-epub-file-with-google-app.html) ○ [RSSToEPUB](https://goo.gl/YCDDBo) ◎ [google/google-apps-script-samples](https://github.com/google/google- apps-script-samples) ◎ [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)
  • 44. Thanks! Any questions? You can find me at: http://kaichu.io cage.chung@gmail.com