Home > OS >  Google Apps Script: Create Google Shared Drive Folder from a Google Form submission
Google Apps Script: Create Google Shared Drive Folder from a Google Form submission

Time:03-18

I found this thread on creating a folder in Google Drive from a Google Form submission. Can any one help me on creating a folder but in Google Shared Drives instead from Google Form submission.

Thank you

CodePudding user response:

If you want to create a new folder in the Shared Drive by modifying the following script,

function createFolder(form) {
  var items = form.response.getItemResponses()
  var name = items[0].getResponse();
  DriveApp.createFolder(name);
}

How about the following modification? In the current stage, fortunately, the folder ID is used, you can access the Shared Drive with Drive service.

Modified script:

function createFolder(form) {
  var folderId = "###"; // Please set the folder ID on the Shared Drive. If you want to create a new folder to the root folder of the Shared Drive, please set the Drive ID here.

  var items = form.response.getItemResponses()
  var name = items[0].getResponse();
  DriveApp.getFolderById(folderId).createFolder(name);
}
  • In this modification, folderId is the folder ID of the specific folder in the Shared Drive or the Drive ID of the Shared Drive. When the Drive ID is used, the folder is created to the root folder of the Shared Drive.

Note:

  • In this case, you are required to have permission for writing to the Shared Drive. Please be careful about this.

Reference:

  • Related