Putting Together the Pieces
Building Apps with Google Apps Script
Saurabh Gupta
Product Manager, Google
?
?
?
?
DriveEye - Add Folders
DriveEye - Add files to subscribed folders
2011
More Services
GUI Builder
2009
2010
2012
?
Apps Script over the years
Scripts in Spreadsheets
(Custom Functions)
UiApp & Web App
Gallery
Sharing
Scripts in Sites
Introducing
script.google.com
Create
?
?
?
Create scripts in
Google Drive
OR
script.google.com
New!
Did anything change?
All the features of Apps Script are still available
No changes to Services
No changes to Events and Triggers
More
2009
2011
More Services
GUI Builder
2012
?
Scripts in Spreadsheets
(Custom Functions)
2010
UiApp & Web App
Gallery
Sharing
Script in Sites
Container-bound scripts
Containers
Apps Script over the years
New Features of Google Apps Script
Create Standalone Scripts
1
Create
Container-bound vs. Standalone Scripts
Standalone
Container-bound
Create
Standalone vs. Container-bound - Create scripts from script.google.com
Create
Standalone vs. Container-bound Scripts
Standalone
Container-bound
Follow lifecycle of the container
Script gets deleted when parent spreadsheet is trashed
Independent lifecycle
Scripts get created, renamed, trashed from Drive
Create
Standalone vs. Container-bound - Finding Scripts
Standalone
Container-bound
Locate the parent spreadsheet and then go to Script editor.
Create
Standalone vs. Container-bound - Search using Code Snippets
Standalone
Create
Designing DriveEye - 3 Standalone Projects
Create
DriveEye
Main Project
Folder Subscription API
Data Model
What's the best way to build UI and store data?
2009
2012
?
Scripts in Spreadsheets
(Custom Functions)
2010
UiApp
Gallery
Sharing
2011
More Services
GUI Builder
Script in Sites
Apps Script over the years
New Features of Google Apps Script
Create Standalone Scripts
ScriptDb
HtmlService
Create
2
3
1
To Learn more about ScriptDb
"Storing Data using Google Apps Script"
When: June 28th, 2012
Time: 17:15pm
Where: Room 7
Who: Drew Csillag
Create
To Learn more about HtmlService and using client side JS in Apps Script
"Use what you know: Html and JavaScript in Apps Script"
When: June 28th, 2012
Time: 2:45pm
Where: Room 11
Who: Corey Goldfeder
Create
Designing DriveEye - 3 Standalone Projects
Create
DriveEye
Main Project
Folder Subscription API
Data Model
1
2
3
DriveEye - Create three standalone script projects
Create
function User(userId, driveFolders, triggerId) {� this.userId = userId;� this.driveFolders = driveFolders;� this.triggerId = triggerId;�}�function DriveFolder(folderId, folderName, files) {� this.folderId = folderId;� this.folderName = folderName;� // string array of files id� this.files = files;�}
Project 1 - Data model to manage folder subscriptions
Create
APPS SCRIPT
�function addFolderSubscription(folderName)�function getSubscribedFolders()�function removeFolderSubscription(folderName)�function removeUser()�function getUser()
Project 2 - API to manage folder subscriptions
APPS SCRIPT
Create
How to glue standalone projects?
Share scripts to collaborate and organize your code
Create
Share
2012
?
2009
Scripts in Spreadsheets
(Custom Functions)
2010
UiApp & Web App
Gallery
Sharing
2011
More Services
GUI Builder
Script in Sites
Apps Script over the years
New Features of Google Apps Script
Share scripts in a simple way
Create Standalone Scripts
ScriptDb
HtmlService
Create
Share
2
3
1
4
Simple Sharing
Google Docs way to share scripts
Container-bound scripts inherit permissions from the parent
Create
Share
1
2
New!
Understanding Permissions
Two types of permissions View, Edit
All Viewers get Execute permissions
Share Scripts using "Share" button
Create
Share
“How does sharing help me organize my code?”
- Logical User
good ol'
Libraries
Create
Share
3 steps to create script libraries
Share script with view permissions
Save a Version of your script
Share project key
Create
Share
1
2
3
DriveEye
Create
Share
DriveEye - Create Two Libraries
Create
Share
Insert Library Project Key
4 steps for using a script library
1
2
3
4
Create
Share
Select a version
4 steps for using a script library
Create
Share
1
2
3
4
Select an identifier
4 steps for using a script library
Identifier becomes the top level class name for that library
Create
Share
1
2
3
4
Use Library with identifier
4 steps for using a script library
Autocomplete shows all the functions that are available in the library
Create
Share
1
2
3
4
function getNewFolderFromId_(folderId) {� var folder = DocsList.getFolderById(folderId);� var folderName = folder.getName();� // ...� var driveFolder = � new DataModel.DriveFolder(folderId, folderName, fileIds);� return driveFolder;�}
Using data model library
APPS SCRIPT
Create
Share
function getFolders() {� return FolderAlertLib.getSubscribedFolders();�}��function createFolder(folderName) {� return FolderAlertLib.addFolderSubscription(folderName); �}��function removeFolder(folderName) {� return FolderAlertLib.removeFolderSubscription(folderName);�}
Using folder subscription api
APPS SCRIPT
Create
Share
What can I do with scripts?
Create
Share
Deploy
Deploy scripts as web apps
2012
?
2009
Scripts in Spreadsheets
(Custom Functions)
2010
UiApp & Web App
Gallery
Sharing
2011
More Services
GUI Builder
Script in Sites
Apps Script over the years
Understanding Web Apps
Create
Share
Deploy
APPS SCRIPT
Web App
Writes
Access
Uses
Active User
(User on the keyboard)
Bob
Bob's Data
Effective User
Sam
New Features of Google Apps Script
Deploy new type of web apps
Share scripts in a simple way
Create Standalone Scripts
ScriptDb
HtmlService
Create
Share
Deploy
2
3
1
4
5
Scripts run as the end user
Create
Share
Deploy
APPS SCRIPT
Web App
Writes
Access
Uses
Active User == Effective User
Sam's Data
Sam
Advantages of scripts running as active user
Create
Share
Deploy
Two types of Web Apps
Create
Share
Deploy
APPS SCRIPT
Web App
Active User and Effective User is the same end-user
Active User is the end user
Effective User is the developer
New!
How to Deploy a web app
Create
Share
Deploy
Select versions
Select type of web app
Access Control
Versioning for Web Apps
Create
Share
Deploy
�function doGet(e) {� var html = HtmlService.createFromFile(...);� // ... more code� // ... more ui code� return htmlOutput;�}
DriveEye - Writing a simple web app
Create
Share
Deploy
APPS SCRIPT
function addFolderSubscription(folderName) {� // ...� // create a new trigger� var triggerId =
ScriptApp.newTrigger("hasNewFiles")� .timeBased().everyMinutes(5)
.create().getUniqueId();� // ... �}
DriveEye - Creating Triggers for each user
APPS SCRIPT
Create
Share
Deploy
How do users find your web app?
Create
Share
Deploy
Publish
2012
?
2009
Scripts in Spreadsheets
(Custom Functions)
2010
UiApp & Web App
Gallery
Sharing
2011
More Services
GUI Builder
Script in Sites
Apps Script over the years
New Features of Google Apps Script
Integration with Chrome Web Store
Deploy new type of web apps
Share scripts in a simple way
Create Standalone Scripts
ScriptDb
HtmlService
2
3
1
4
5
6
Create
Share
Deploy
Publish
Create
Share
Deploy
Publish
New!
What's so special about Chrome Web Store integration?
Create
Share
Deploy
Publish
Verify the ownership using Google Webmaster Central
Create
Share
Deploy
Publish
1
2
3
4
Register the Web App in Chrome Web Store
Create
Share
Deploy
Publish
1
2
4
3
Customize Listing Chrome Web Store
Create
Share
Deploy
Publish
1
2
3
4
Publish and go live !
Create
Share
Deploy
Publish
1
2
3
4
Create
Share
Deploy
Publish
Completing the story
DriveEye
Shared Folder Notifications
Demo of DriveEye
New Features of Google Apps Script
Integration with Chrome Web Store
Deploy new type of web apps
Share scripts in a simple way
Create Standalone Scripts
ScriptDb
HtmlService
2
3
1
4
5
6
Create
Share
Deploy
Publish
script.google.com
#io12
script.google.com
#io12