20
Google App Script Aakash Goel http://gplus.to/aakashg Don't Hate, Automate!

GAS Session

  • Upload
    bvcoe

  • View
    429

  • Download
    0

Embed Size (px)

DESCRIPTION

GDG BVP Presentation on Google App Script by Aakash Goel. Date:27-09-2012

Citation preview

Page 1: GAS Session

Google App Script

Aakash Goel

http://gplus.to/aakashg

Don't Hate, Automate!

Page 2: GAS Session

© Copyright GDG BVP 2012

Raise your hand

Ever heard of Google App Script?

Who uses Google Drive?

Google Docs???

Page 3: GAS Session

© Copyright GDG BVP 2012

Agenda

Is Apps Script for you?

Features of Apps Script ServicesoDocs ServicesoMail, Calendar, ContactsoIntegration ServicesoUI ServicesoUtilities & Debugger

Demos

Getting Started

Page 4: GAS Session

© Copyright GDG BVP 2012

WHAT is App Script?

JavaScript engine in the cloud

o JavaScript Runtimeo Execute on Google's cloudo Integrates with Google's Services

Comes with

o JavaScript syntax and base classeso Built-in access to various Google APIso Ability to integrate 3rd party serviceso Online editor: Write code in the browser

Page 5: GAS Session

© Copyright GDG BVP 2012

WHY App Script?

Easy to Use

oWrite on the web, run on the weboNo hardware, software, deployments, maintenance etc..oJavaScript syntax

Don't hate, Automate!

Page 6: GAS Session

© Copyright GDG BVP 2012

WHERE is App Script?

Executed in a variety of different ways

o Spreadsheet

o Google Sites

o Standalone with Custom UI

o Asynchronous Triggers

Page 7: GAS Session

© Copyright GDG BVP 2012

WHO can use App Script?

Anyone CAN SCRIPT!

Page 8: GAS Session

© Copyright GDG BVP 2012

WHO can use App Script?

Page 9: GAS Session

© Copyright GDG BVP 2012

App Script Services

Google products

o Spreadsheeto Siteso DocList

o Gmailo Contactso Calendar

o Mapso Finance ...

Page 10: GAS Session

© Copyright GDG BVP 2012

App Script Services

External services

oURL Fetch + OAutho JDBCo SOAPo XML

Other

oUI Serviceso WYSIWYG Editoro Charts

Page 11: GAS Session

© Copyright GDG BVP 2012

Triggers

Triggers allow asynchronous execution of scripts

Types of Triggers:

oEvent DrivenoTime Driven

Advantage:

Helps in Automation

Page 12: GAS Session

© Copyright GDG BVP 2012

Demos

Save Gmail attachment automatically to Drive

goo.gl/YLm2W

MCQ tests: email score & correction

Drive Eye

Flubaroo

Page 13: GAS Session

© Copyright GDG BVP 2012

Need a Break??

Page 14: GAS Session

© Copyright GDG BVP 2012

Getting Started

Page 15: GAS Session

© Copyright GDG BVP 2012

Hello World

function myFunction() {

  // Create a new document with the title 'Hello World'  var doc = DocumentApp.create('Hello World');

  // Add a paragraph to the document  doc.appendParagraph('This document was created by my first Google Apps Script.');

  // Save and close the document  doc.saveAndClose();

}

Page 16: GAS Session

© Copyright GDG BVP 2012

Hello World

function myFunction() { …

// Get the URL of the document  var url = doc.getUrl();

  // Get the email address of the active user - that's you  var emailAddress = Session.getActiveUser().getEmail();

  // Send yourself an email with a link to the document  GmailApp.sendEmail(emailAddress, “Hello World', ‘Link to a document created by my ' +                     'first Google Apps Script: ' + url);}

Page 17: GAS Session

© Copyright GDG BVP 2012

Custom Spreadsheet Function

function c2f(inp) {

  // Function to convert from Celsius to Fahrenheit.  var out = 0;     // this will hold the answer

 if (typeof inp != "number") {  // check to make sure the input is a number    throw "Input value must be a number";  // throw an exception with the error message  }

  out = (inp*9)/5 + 32;  // calculate the answer  return out;  // return the answer to the cell which has the formula

}

Page 18: GAS Session

© Copyright GDG BVP 2012

Calendar Event

function myFunction() {

//Create an object of the Default calender in use.      var calender = CalendarApp.getDefaultCalendar(); //startDate will correspond to the current date and time.        var startDate = new Date();

//endDate will be same as the startDate.      var endDate = new Date(startDate); //Increment the hours of endDate by 2 as the duration of the event is 2 hrs.      endDate.setHours(startDate.getHours() + 2); //Create the Event.   var event = calender.createEvent("Hackathon", startDate, endDate);                   

}

Page 19: GAS Session

© Copyright GDG BVP 2012

Contact Me

Google Plushttp://gplus.to/aakashg

Twitter@goelaakash9

Email [email protected]

Page 20: GAS Session

© Copyright GDG BVP 2012

Feedback

Feedback Form

http://goo.gl/jLzWu