SlideShare a Scribd company logo
2
Most read
4
Most read
8
Most read
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

More Related Content

PPTX
GDSCUIZ: Intro to Google Workspace
PDF
Introduction to Slack
PDF
Google apps script introduction
PPTX
Introduction to iOS Apps Development
PDF
Social media with big data analytics
PDF
Why and how to use slack
PPTX
MDX (Multi Dimensional Expressions) Introduction
PDF
Processing Large Datasets for ADAS Applications using Apache Spark
GDSCUIZ: Intro to Google Workspace
Introduction to Slack
Google apps script introduction
Introduction to iOS Apps Development
Social media with big data analytics
Why and how to use slack
MDX (Multi Dimensional Expressions) Introduction
Processing Large Datasets for ADAS Applications using Apache Spark

What's hot (20)

PDF
Introduction to Android Development
PDF
Introduction to slack and how my team used it
PPTX
PPT - Google Data Studio
PPTX
TechUp 2019 Microsoft Teams
PPTX
Google Data Studio for business
PPTX
Introduction to Mobile Development
PPTX
Presentation On Slack
PDF
Data visualisation & analytics with Tableau
PPTX
Google Data Studio NC Tech 4 Good
PPTX
PPTX
Mendix Accelerates the Software Lifecycle
PDF
Publish Android Application on Google Play Store
PPTX
Power BI visuals
PDF
Supporting multiple screens on android
PPTX
Introduction to Android and Android Studio
PPTX
Using Slack For Internal Communications
PPTX
Google data studio
PPT
Mobile Application Development
PPTX
Overview of Microsoft Appliances: Scaling SQL Server to Hundreds of Terabytes
Introduction to Android Development
Introduction to slack and how my team used it
PPT - Google Data Studio
TechUp 2019 Microsoft Teams
Google Data Studio for business
Introduction to Mobile Development
Presentation On Slack
Data visualisation & analytics with Tableau
Google Data Studio NC Tech 4 Good
Mendix Accelerates the Software Lifecycle
Publish Android Application on Google Play Store
Power BI visuals
Supporting multiple screens on android
Introduction to Android and Android Studio
Using Slack For Internal Communications
Google data studio
Mobile Application Development
Overview of Microsoft Appliances: Scaling SQL Server to Hundreds of Terabytes
Ad

More from Martin Hawksey (20)

PDF
What about GDPR?
PDF
Twitter in Education: Interactively exploring the conversation with TAGS and ...
PPTX
TEL Quality and Innovation: What can be learned from the history of computer ...
PPTX
Making the complex less complicated: An introduction to social network analysis
PPTX
Measuring Social Media Impact: Google Analytics and Twitter
PPTX
Google Apps Script the Authentic{ated} Mobile Playground
PPTX
Using CiviCRM in Google Drive with the new CiviService Google Script Library
PDF
Google Analytics Workout (#IWMW16)
PPTX
Extracting and analyzing discussion data with google sheets and google analytics
PPTX
Using WordPress as a badge platform #openbadgesHE
PPTX
Looking at creativity and culture in computer science to inspire better educa...
PPTX
Google Apps Script: The authentic{ated} playground [2015 Ed.]
PPTX
Creating personal tutoring environments with Google Apps Script
PPTX
Learning analytics gaining good actionable insight
PPTX
Custom reporting from CiviCRM with Google Sheets
PPTX
Learning analytics: Threats and opportunities
PPTX
Google Apps Script: The Authentic{ated} Playground
PPTX
Breaking the Cell #WebExpo
PPTX
Open Badges in Open Education – Do They Count? #eas14
PPTX
ocTEL and Open Badges #altc
What about GDPR?
Twitter in Education: Interactively exploring the conversation with TAGS and ...
TEL Quality and Innovation: What can be learned from the history of computer ...
Making the complex less complicated: An introduction to social network analysis
Measuring Social Media Impact: Google Analytics and Twitter
Google Apps Script the Authentic{ated} Mobile Playground
Using CiviCRM in Google Drive with the new CiviService Google Script Library
Google Analytics Workout (#IWMW16)
Extracting and analyzing discussion data with google sheets and google analytics
Using WordPress as a badge platform #openbadgesHE
Looking at creativity and culture in computer science to inspire better educa...
Google Apps Script: The authentic{ated} playground [2015 Ed.]
Creating personal tutoring environments with Google Apps Script
Learning analytics gaining good actionable insight
Custom reporting from CiviCRM with Google Sheets
Learning analytics: Threats and opportunities
Google Apps Script: The Authentic{ated} Playground
Breaking the Cell #WebExpo
Open Badges in Open Education – Do They Count? #eas14
ocTEL and Open Badges #altc
Ad

Recently uploaded (20)

PPTX
Cell Types and Its function , kingdom of life
PDF
A systematic review of self-coping strategies used by university students to ...
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Lesson notes of climatology university.
PDF
01-Introduction-to-Information-Management.pdf
PDF
RMMM.pdf make it easy to upload and study
Cell Types and Its function , kingdom of life
A systematic review of self-coping strategies used by university students to ...
STATICS OF THE RIGID BODIES Hibbelers.pdf
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Anesthesia in Laparoscopic Surgery in India
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Microbial diseases, their pathogenesis and prophylaxis
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
2.FourierTransform-ShortQuestionswithAnswers.pdf
Final Presentation General Medicine 03-08-2024.pptx
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
VCE English Exam - Section C Student Revision Booklet
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
Chinmaya Tiranga quiz Grand Finale.pdf
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Abdominal Access Techniques with Prof. Dr. R K Mishra
Lesson notes of climatology university.
01-Introduction-to-Information-Management.pdf
RMMM.pdf make it easy to upload and study

Introduction to Google Apps Script

  • 1. Introduction to Google Apps Script On form submit filter data to sheets Martin Hawksey @mhawksey
  • 2. 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
  • 3. Solution 1 - Filter the data http://mashe.hawksey.info
  • 4. 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
  • 5. How I see it http://mashe.hawksey.info
  • 6. How you write it In Spreadsheets Tools > Script Editor In Sites Manage Site > Apps Script http://mashe.hawksey.info
  • 7. How does the user interact with it In Spreadsheets In Sites As a service http://mashe.hawksey.info
  • 8. 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
  • 9. 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
  • 10. 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
  • 11. 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
  • 12. Not forgetting your friendly EdTech explorer Email: martin@hawksey.info Blog: http://mashe.hawksey.info Tweet: @mhawksey http://mashe.hawksey.info
  • 13. 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
  • 14. 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