Last active
August 29, 2015 14:25
-
-
Save MrOrz/01cd90a19544fa1100b4 to your computer and use it in GitHub Desktop.
This script adds a trigger to a Google Form to automatically setup submitted email to become an editor of a specific Google document.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Inviteyoself for Google Doc | |
=========================== | |
Google doc currently records who edited the file if the file is *not* set to `Anyone can edit'. | |
We cannot track the author of edits in documents that is set to `Anyone with the link can edit'. | |
This script adds a trigger to a Google Form to automatically setup submitted email to become an | |
editor of a specific Google document. | |
Setup | |
----- | |
0. Fill in GOOGLE_DOC_ID with the Google document ID you want to share. | |
1. Create a Google spreadsheet and add a form that asks for users' email. | |
Question for the email must be of type "text" and its title should match QUESTION_TITLE, | |
which is seen below. | |
2. In the spreadsheet of the form, open up Script editor using Tools > Scripts editor... | |
3. Copy-paste the content of this gist and save the Google scripts project | |
4. In Script editor, click Resources > Current project's triggers to open up trigger setup. | |
Set it up like this: http://i.imgur.com/URt03Gg.png | |
so that onFormSubmit() can be run on form submit in current spreadsheet. | |
*/ | |
var QUESTION_TITLE = 'Email', | |
GOOGLE_DOC_ID = 'GOOGLE_DOC_ID_HERE', | |
file = DriveApp.getFileById(GOOGLE_DOC_ID); | |
function onFormSubmit(e) { | |
file.addEditor(e.namedValues[QUESTION_TITLE][0]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment