google apps for education

Boost your Google Forms with custom script

google apps for educationWell, couple months ago I started the implementation of Google Apps for Education at high school. Funny job, really. Anyway I still see surprised faces when I show them Google Apps Scrips. Our team was able to rebuilt the whole document workflow and move it to cloud.

Because Google Script is very powerfull tool for Google Apps users and administrators, I decided to share some of features we used. This time it will be all about Google Forms workflow.

Use case

Here is one example that we solved:

Teacher must be able to add new entry about meeting (date, description, attendants, …), then the meeting summary has to be sent for approval, confirmed, archived and print.

How to

Because we wanted to avoid copy-paste & Word-version hell, we figured out this solution:

First, it was necessary to create Google Form (don’t know what are Google Forms?) and share it to teachers. This created the interface for entering new summary meetings. Than in Google Spreadsheet connected to Google Form we added new workflow script something like this:

Open Google Spreadsheet with future answers, click on Tools->Script Editor and add new function

// Grab last line, get data and create new Document
// date was captured from answer's spreadsheet
 var doc = DocumentApp.create('Meeting Summary ' + date);

// insert and format data from spreadsheet to new document
// here we appended all information thet teacher enter to our Form
 var body = doc.getBody();
 var summaryTitle = body.appendParagraph('Our title');

//next add email of person, that has to approve this summary
 DocsList.getFileById(doc.getId()).addEditor('who-will@approve.it');

//generate link to google document with summary and send it
 var url = DocsList.getFileById(doc.getId()).getUrl();
 MailApp.sendEmail('who-will@approve.it', 'New meeting summary to approve', 'Click here to view the summary: ' + url);

Once script was done, we created new trigger to automatically run this script whenever new summary is added via Form.

Results

All above is now creating new Google document and share it to responsible person. They don’t have to copy&paste responses from spreadsheet, email between each other etc. Instead they have nice “Word-like” document ready for approval and print seconds after submition by Form.

The new document also has script inside, which generate menu with two items: Approve and Return. Once clicked on Approve, document is moved to archive and printed. If clicked on Return, document is shared back to teacher with comments.