• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Introduction to Google Apps Script
 

Introduction to Google Apps Script

on

  • 3,269 views

Slides used in a presentation to introduce Google Apps Script and solve the problem of automatically creating new sheet for each user completing a form

Slides used in a presentation to introduce Google Apps Script and solve the problem of automatically creating new sheet for each user completing a form

Statistics

Views

Total Views
3,269
Views on SlideShare
3,269
Embed Views
0

Actions

Likes
2
Downloads
14
Comments
0

0 Embeds 0

No embeds

Accessibility

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

CC Attribution License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Introduction to Google Apps Script Introduction to Google Apps Script Presentation Transcript

    • Introduction to Google Apps Script On form submit filter data to sheets Martin Hawksey @mhawksey
    • The Problem
      • Hi there, I'm trying to get some student PT's to complete a training diary using a Google form. I would like the form to automatically create a new sheet for each user.  I should ultimately have 42 entries per user/sheet.
      • http://www.google.com/support/forum/p/Google+Docs/thread?tid=6fe8356595e9b859&hl=en
      http://mashe.hawksey.info
    • Solution 1 - Filter the data http://mashe.hawksey.info
    • Solution 2 – Google Apps Script
      • Google Apps Script is a JavaScript cloud scripting language that provides easy ways to automate tasks across Google products and third party services.
      • http://code.google.com/googleapps/appsscript/
      http://mashe.hawksey.info
    • How I see it http://mashe.hawksey.info
    • How you write it
      • In Spreadsheets
        • Tools > Script Editor
      • In Sites
        • Manage Site > Apps Script
      http://mashe.hawksey.info
    • How does the user interact with it
      • In Spreadsheets
      • In Sites
      • As a service
      http://mashe.hawksey.info
    • There’s good and bad news
      • Bad news
        • You need basic programming skills to write
      • Good news
        • Already a growing number of developers publishing scripts and tutorials for you to reuse e.g. http://www.flubaroo.com/
      http://mashe.hawksey.info
    • Lets do it
      • https://spreadsheets.google.com/a/hawksey.info/spreadsheet/ccc?key=0Alq6_NgDnxLWdENvZHhwVm93TjRhTm5fcjU0X0t3Vnc
      • Logins: [email_address]
      • [email_address]
      • [email_address]
      • Password: *******
      http://mashe.hawksey.info
    • Explanation of Javascript Objects got by getValues()
      • data = [[“Dog”,”Cat”,”Cow”],[22, 31, 15],[6, 5, 5]]
      • data[0] = [“Dog”,”Cat”,”Cow”]
      • data[0][1] = “Cat”
      http://mashe.hawksey.info Dog Cat Cow 22 31 15 6 5 5
    • Useful links
      • Workshop material from Open4Ed
        • http://mashe.hawksey.info/2011/05/app-app-and-away-workshop-handout-open4ed-gas/
      • Simple Apps Solutions (free Apps Script consultancy for Ed and tutorials)
        • http://simpleappssolutions.com
      • Official Apps Script Site
        • Docs
        • Tutorials
        • Help forum
      http://mashe.hawksey.info
    • Not forgetting your friendly EdTech explorer
      • Email: martin@hawksey.info
      • Blog: http://mashe.hawksey.info
      • Tweet: @mhawksey
      http://mashe.hawksey.info
    • Pseudo-code
      •   // onFormSubmit
      • // get submitted data   // check if username has sheet   //    if not make   // copy submitted data to user's sheet
      http://mashe.hawksey.info
    • Final code
      • function onFormSubmit() {
      • // onFormSubmit
      • // get submitted data
      • var ss = SpreadsheetApp.getActiveSpreadsheet();
      • var sheet = ss.getSheetByName("Form_Sheet");
      • var headings = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues();
      • var lastRow = sheet.getRange(sheet.getLastRow(), 1, 1, sheet.getLastColumn()).getValues();
      • var studentUsername = lastRow[0][1];
      • // check if username has sheet
      • if(ss.getSheetByName(studentUsername)){
      • var userSheet = ss.getSheetByName(studentUsername);
      • // if not make
      • } else {
      • var userSheet = ss.insertSheet(studentUsername);
      • userSheet.getRange(1, 1 , 1, headings[0].length).setValues(headings);
      • }
      • // copy submitted data to user's sheet
      • userSheet.getRange(userSheet.getLastRow()+1, 1, 1, lastRow[0].length).setValues(lastRow);
      • }
      http://mashe.hawksey.info