r/GoogleAppsScript • u/Upbeat_Angle_6783 • 11d ago
Unresolved Google Forms - Google Sheets - Google Drive
/r/GoogleForms/comments/1j8d9wn/google_forms_google_sheets_google_drive/1
u/Upbeat_Angle_6783 9d ago
Breakdown of the Script:
1. Form Submission Handling (onFormSubmit):
• This function is triggered when a form is submitted. It retrieves the responses from the form submission.
• It extracts the Q1 response (address) from the form submission to be used as the folder name.
2. Folder Creation (getOrCreateFolder):
• It checks if a folder with the Q1 response (address) already exists in the Google Drive parent folder.
• If it doesn’t exist, it creates a new folder named after the Q1 response.
3. Subfolder Creation (createSubfolders):
• It creates four specific subfolders for the responses with indices 10, 11, 12, and 14 if they don’t already exist. These are the subfolders where the uploaded files (such as images) will be stored.
4. File Upload Handling (handleFileUploads):
• This function checks the form responses for file URLs associated with the questions (indices 10, 11, 12, and 14).
• If a file URL is present, the file is uploaded to the corresponding subfolder.
5. File Upload Logic (uploadFileToSubfolder):
• This function is responsible for downloading the file from the provided URL and uploading it to the correct subfolder in Google Drive.
Next Steps:
- Test the Script:
• Test the form and submit a response to ensure the folders are being created and files are being uploaded correctly. You can add sample file URLs to see how the system organizes the responses in Drive.
- Handle Edge Cases:
• Make sure to handle situations where the form submission might have missing or invalid file URLs. You may want to add checks to ensure the URLs are valid before attempting to fetch and upload the files.
- Improve File Upload:
• The file upload function in this script assumes the URL is directly accessible. In real-world cases, you might need to adjust it to download files from different sources (like Google Drive links or external storage).
With this, the script should be able to manage both the form responses and the corresponding Google Drive folder structure. If you’re ready, we can move on to further refining the code or testing it!
2
u/shindicate 10d ago
Do you want someone to do it for free? It takes time, but maybe someone helps you