Extending Google Apps/Spreadsheet using Google Apps Script

  • Published on
    23-Jan-2017

  • View
    648

  • Download
    5

Embed Size (px)

Transcript

<ul><li><p>Presented at GDG DevFest Ahmedabad 2015</p><p>Presented By : Dipali VyasProject Manager @ Zestard Technologies</p><p>Date: 27-Dec-2015</p><p>Google Apps Script</p><p>http://www.zestard.com/</p></li><li><p>What is GAS - Google Apps Script? </p><p>And What Magic we are going to see.</p><p>Google Apps Script is a JavaScript cloud scripting language to automate tasks</p><p> Editor in a browser &amp; managed in cloud (no install/setup, files stored,shared, versioned)</p><p> JavaScript runtime in the cloud ( compliant, debuggable, and performant )</p><p> Set of APIs and hooks to Google products (extend and enhance, built in security, distribution mechanisms</p><p>2</p><p> 11 Google apps, 1 platform in the cloud</p></li><li><p>Getting Started with Google Apps Script (GAS)</p><p> Standalone script https://script.google.com Google Drive &gt; Create &gt; More &gt; Script **</p><p> Spreadsheet/App-bound script Tools &gt;Script Editor **</p><p> Sites-bound script More &gt; Manage Site &gt; Apps Scripts &gt; Add new script **</p><p>** Do take care of the Authorization Step while scripting</p><p>3</p></li><li><p>Standalone Script Example </p><p>function createAndSendDocument() {</p><p> // Create a new Google Doc named 'DevFestAhm15 GAS Demo1'</p><p> var doc = DocumentApp.create('DevFestAhm15 GAS Demo1');</p><p> // Access the body of the document, then add a paragraph.</p><p> doc.getBody().appendParagraph('This document was created by Google Apps Script-Standalone Script. This is part of DevFestAhm15 GAS Demo1 provided by Dipali Vyas during the presentation in front of excellent participants of the session ');</p><p> // Get the URL of the document.</p><p> var url = doc.getUrl();</p><p> // Get the email address of the active user - that's you.</p><p> var email = Session.getActiveUser().getEmail();</p><p> // Get the name of the document to use as an email subject line.</p><p> var subject = doc.getName();</p><p> // Append a new string to the "url" variable to use as an email body.</p><p> var body = 'Link to your doc created at DevFestAhm15 : ' + url;</p><p> // Send yourself an email with a link to the document.</p><p> GmailApp.sendEmail(email, subject, body);</p><p>}</p><p>==========End</p><p>4</p></li><li><p>Spreadsheet/ App Bound Script Example </p><p>Bound scripts can call a few methods :</p><p> getActiveSpreadsheet(), getActiveDocument(), and getActiveForm() allow bound scripts to refer to their parent file without referring to the file's ID.</p><p> getUi lets bound scripts access the user interface for their parent file to add custom menus, dialogs, and sidebars.</p><p> In Google Sheets, getActiveSheet(), getActiveRange(), and getActiveCell() let the script determine the user's current sheet, selected range of cells, or selected individualcell.setActiveSheet(sheet) and setActiveRange(range) let the script change those selections.</p><p> In Google Docs, getCursor() and getSelection() let the script determine the position of the user's cursor or selected text. setCursor(position) and setSelection(range) let the script change those locations.</p><p>5</p><p>https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet-app#getActiveSpreadsheet()https://developers.google.com/apps-script/reference/document/document-app#getActiveDocument()https://developers.google.com/apps-script/reference/forms/form-app#getActiveForm()https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet-app#getUi()https://developers.google.com/apps-script/guides/bound#custom_menus_dialogs_and_sidebarshttps://developers.google.com/apps-script/reference/spreadsheet/spreadsheet-app#getActiveSheet()https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet-app#getActiveRange()https://developers.google.com/apps-script/reference/spreadsheet/sheet#getActiveCell()https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet-app#setActiveSheet(Sheet)https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet-app#setActiveRange(Range)https://developers.google.com/apps-script/reference/document/document#getCursor()https://developers.google.com/apps-script/reference/document/document#getSelection()https://developers.google.com/apps-script/reference/document/document#setCursor(Position)https://developers.google.com/apps-script/reference/document/document#setCursor(Position)https://developers.google.com/apps-script/reference/document/document#setSelection(Range)https://docs.google.com/spreadsheets/d/14ZHYnniaW-czGWOe5L0KjNO0_0TAX5690DpNLqnqpg4/edit#gid=0</p></li><li><p>Google Apps Scripts Fundamentals</p><p>6 IntegrationTriggersCustom UICustom UI Menus Sub-Menus Dialogs SideBars</p><p>Triggers Simple </p><p>triggers(built-in functions)</p><p> Installable triggers</p><p>Integration</p><p>With all Google apps, we can initially check</p><p>https://docs.google.com/spreadsheets/d/14ZHYnniaW-czGWOe5L0KjNO0_0TAX5690DpNLqnqpg4/edit#gid=26440790https://docs.google.com/spreadsheets/d/14ZHYnniaW-czGWOe5L0KjNO0_0TAX5690DpNLqnqpg4/edit#gid=26440790https://docs.google.com/spreadsheets/d/14ZHYnniaW-czGWOe5L0KjNO0_0TAX5690DpNLqnqpg4/edit#gid=26440790</p></li><li><p>Triggers in Apps Script</p><p>A trigger is a type of script resource that listens for a particular event and executes a function when that event fires.</p><p> Simple triggers Specially-named built-in functions that are </p><p>specific to spreadsheets onEdit onOpen onInstall</p><p> Installable triggers Time-based triggers Container-bound installable triggers (let's make </p><p>one!)</p><p>7</p></li><li><p>Use Cases</p><p>App Reference #1</p><p>Grading made easy with Flubaroo </p><p> Create quiz using Google Forms Automatically grades against </p><p>answer key Can email results and answers to </p><p>each student Provides charts to analyze the </p><p>results</p><p>8</p><p>https://docs.google.com/spreadsheets/d/1NK7BWCLYyvhs-PIGXIh2FfWNR7Pofms6qm6DKYAGK3A/edit#gid=457145258https://docs.google.com/spreadsheets/d/1NK7BWCLYyvhs-PIGXIh2FfWNR7Pofms6qm6DKYAGK3A/edit#gid=457145258https://docs.google.com/spreadsheets/d/1NK7BWCLYyvhs-PIGXIh2FfWNR7Pofms6qm6DKYAGK3A/edit#gid=457145258</p></li><li><p>Use Cases</p><p>App Reference #2</p><p>Many types of mail merge </p><p> Define a simple template using a draft email, document, sites page, or spreadsheet cell</p><p> Add placeholder values that should be dynamically replaced</p><p> Each spreadsheet row merged with template and sent out</p><p> (Example of MailMerge by Amit Agrawal)</p><p>9</p><p>https://docs.google.com/spreadsheets/d/14ZHYnniaW-czGWOe5L0KjNO0_0TAX5690DpNLqnqpg4/edit#gid=1840749483https://docs.google.com/spreadsheets/d/14ZHYnniaW-czGWOe5L0KjNO0_0TAX5690DpNLqnqpg4/edit#gid=1840749483https://docs.google.com/spreadsheets/d/14ZHYnniaW-czGWOe5L0KjNO0_0TAX5690DpNLqnqpg4/edit#gid=1840749483https://docs.google.com/spreadsheets/d/14ZHYnniaW-czGWOe5L0KjNO0_0TAX5690DpNLqnqpg4/edit#gid=1840749483</p></li><li><p>Easy Reference for the Beginners</p><p> http://developers.google.com/apps-scriptUser guide covering basic functionality30+ tutorials with code Videos </p><p> YouTube channels </p><p> GoogleDevelopers and GoogleApps Stack Overflow Tag questions with google-apps-script )</p><p> Very active community, Google moderated Google Apps Developer Blog</p><p>10</p><p>http://developers.google.com/apps-scripthttp://developers.google.com/apps-scripthttp://developers.google.com/apps-script</p></li><li><p>11 THANKS!Any questions?</p><p>Special thanks to all the people who made and released these awesome resources for free.</p></li><li><p>Google Apps Script</p><p>Presented at GDG DevFest Ahmedabad 2015</p><p>Presented By : Dipali VyasProject Manager @ Zestard Technologies</p><p>Date: 27-Dec-2015</p><p>Email: dipalia@gmail.com</p><p>Twitter: @dipalia</p><p>http://www.zestard.com/</p></li></ul>