LogoLogo
Gilmour AcademyComputer Science
  • Gilmour's Online Guide
  • Orientation
    • 0: Safety
    • 1: Microsoft Account
    • 2: Login to Chrome
    • 3: Gmail
    • 4: Portal (LMS)
    • 5: Google Drive app
    • 6: Printing
    • 7: Security
    • 8: More Tools
  • Content Creation
    • Presentations
    • Paper to PDF
    • Record Your Screen
    • WeVideo
    • Flipgrid
    • Google Sites
    • Record Audio
  • Organization
    • Todoist
    • Trello
  • Educators
    • Teacher Essentials
      • Portal (LMS)
      • Gmail
      • Google Drive
      • Chalk and Curriculum
      • Planboard
      • Google Forms
      • Projectors & TVs
    • Class Toolkit
      • Lesson Content
      • Pear Deck
      • Booking Meetings
      • EdPuzzle
      • Media Projects
      • Gamification
      • Other Web Meetings
    • Advanced
      • Virtual Classroom
        • Good Student Habits
        • Zoom
        • Internet Access
        • Virtual Lesson Model
      • User Experience
      • Google Forms Scripts
      • Fillable PDF or Doc
      • Fancy Web Elements
    • Glave: Logging Experience
      • Student's Perspective
      • Parent's Perspective
      • Mentor's Perspective
      • Advisor's Perspective
      • Manager's Perspective
      • Glossary
Powered by GitBook
On this page
  • Script editor
  • Challenge #1
  • What our script will do
  • Solution
  • Triggers

Was this helpful?

  1. Educators
  2. Advanced

Google Forms Scripts

Google and Microsoft both allow people to use a little bit of code to make a big impact.

PreviousUser ExperienceNextFillable PDF or Doc

Last updated 5 years ago

Was this helpful?

Script editor

Challenge #1

Let's imagine you're running a new program during a sort of free period at school. You need to track students that have the choice of multiple locations. You don't have time to get your school's attendance system in line with this new, flexible program. Instead, you'd like to share a Google Sheet with all your students and have teachers quickly note student locations using that form.

What our script will do

All we've been asked to do is automatically create a new column for every weekday. Column A will be the student's name. Column B needs to be today.

None of this should be memorized. Use the patient power of GoogleFu to work the problem.

Solution

function dailyColumn() {
  // create a variable that accesses all tabs of my spreadsheet
  var ss = SpreadsheetApp.getActiveSheet();
  
  // create a variable that contains the first sheet
  var sheet = ss.getSheets()[0];
  
  // insert a new column (not zero-indexed like the line above)
  sheet.insertColumnBefore(2); 
  
  // add the date to the column
  var date = Utilities.formatDate(new Date(), "GMT-4", "dd/MM/yyyy");
  sheet.getRange('B2').setValue(date);

}
  

Triggers

Now that we have our solution, we need to have it auto-run every day. For that we'll need to wade into Google's G Suite Developer Hub.

Google Forms script editor uses JavaScript.

Don't be afraid to study up a bit.