Created
September 13, 2017 18:07
-
-
Save jaflo/278e83af2e1bf58ea41dabce44bd7b1e to your computer and use it in GitHub Desktop.
Share folder with user once they fill out a Google form
This file contains 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
/* | |
1. Open or create your form. | |
2. Click the wheel icon, check "Collect email addresses", save. This will automatically get the email from the user. | |
* In the survey, you should probably put some text that explains that it will automatically use their account's email. | |
3. Click the three dots in the top right, select "Script Editor." | |
4. Copy this entire file and paste it in the editor. | |
5. Replace your_folder_id with your folder ID. | |
* To find the folder ID, open the folder you wish to share on the web. | |
* In the address bar, it should be something like https://drive.google.com/drive/u/0/folders/0B1jVrClv_7PllGlxTz4YjXRCeFk | |
* 0B1jVrClv_7PllGlxTz4YjXRCeFk is your folder ID. | |
6. Make sure the script looks alright. | |
7. Select Edit > Current project's triggers from the toolbar. You might need to name the project. | |
8. Click "Click here to add one now." to add a trigger. | |
9. Add a trigger: | |
* Run: addNewUser | |
* Events: From form, On form submit | |
10. Save. Name the project if needed. Review Permissions: | |
* Choose your account if needed. | |
* There is a safety warning since you wrote the script yourself. | |
* Click "Advanced" in the bottom left. | |
* Trust, click "Go to Untitled project (unsafe)." | |
* Type continue in the textbox if needed. | |
* Click "Allow." | |
11. You're done! | |
*/ | |
function addNewUser(e) { | |
var email = e.response.getRespondentEmail(); | |
var sheet = DriveApp.getFolderById("your_folder_id"); | |
sheet.addEditor(email); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment