I created a script to create a new folder every time a form is submitted. The point of the script was to put each newly created folder in a specific parent folder determined by a column value on a spreadsheet (new values are generated when forms are submitted). At the moment the script does not fire automatically even though a trigger event is setup, but will fire and create the new folder in the proper location when manually run. Any help would be appreciated.
function createNewFolder() {
// identify the sheet where the data resides
var ss = SpreadsheetApp.getActive();
var names = ss.getSheetByName("Form Responses 1");
var ids = ss.getSheetByName("Form Responses 1");
//identify the cell that will be used to name the folder
var getName = names.getRange(names.getLastRow(), 3).getValue();
//identify the cell that determines which parent folder to use
var folderId = ids.getRange(ids.getLastRow(), 5).getValue();
//identify the parent folder the new folder will be in
var parentFolder = DriveApp.getFolderById(folderId);
//create the new folder
var newFolder = parentFolder.createFolder(getName);
}
The trigger fails about 85% of the time and is setup to fire when a new form response is logged on the associated spreadsheet.