Google Workspace + JavaScript = 🎉
Dustin Tauer
dustin@frontendmasters.com
Photo Credit: Andrei Labai
Last JavaScriptMN Presentation: October 25th, 2012
https://developers.google.com/apps-script/
Why is this cool?
JavaScript Knowledge
Power
Getting Started
function onOpen() {
var ui = SpreadsheetApp.getUi();
ui.createMenu('My Custom Item')
.addItem('Menu 1', 'callbackFunction1')
.addItem('Menu 2', 'callbackFunction2')
.addSeparator()
.addItem('Menu 3', 'callbackFunction3')
.addToUi()
}
Code Example: Creating a custom menu
// Code.gs
let template = HtmlService.createTemplateFromFile('Email-Invitation')
template.data = {workshops: data}
let html = template.evaluate().getContent()
let draft = GmailApp.createDraft(
'',
`Frontend Masters Workshops`,
'',
{htmlBody: html}
);
Implementation & UI
// "Printing scriptlets" <?= ?> in HTML Templates
<? for(var i = 0; i < data.workshops.length; i++){ ?>
<p><?= data.workshops[i].workshopName ?><p>
<? } ?>
Authorizing the Application
Demo: Generating Dynamic Gmail Drafts
Thank You!
Dustin Tauer
dustin@frontendmasters.com