I am running into a weird problem where the createFolder function just freezes. I get no error no failure and its just stuck there. I have it running on another sheet with no issue but in this particular project, it gets stuck.
The major difference about this project is that I am using a master sheet to update another sheet when changes occur. I am leveraging variables from the second sheet which I am pulling into the Master sheet. All my connections seem to be in order as far permissions to execute between both sheets. I am the owner of both and I have granted the project the appropriate permissions.
The General code:
var dash = SpreadsheetApp.openById('mysheetid').getSheetByName('config');
//CAPTURE INPUTS
var myName = Browser.inputBox("Enter the Name of the Plan:",Browser.Buttons.OK_CANCEL);
//GET TARGET FOLDER
var rowUID = gl.findCell(na,myUID); //gl is global variable I am pulling in, na is another sheet record
var parentFolder = GetTargetFolder(dash,"E3");//dash secondary sheet record
var folderName = myUID + "-" + myName;
var nFolderId = createFolder(folderName, parentFolder);
var colUID;
I get stuck here:
function createFolder(FolderName, TargetFolder)
{
//FolderName is the name of the folder you want to create
//TargetFolder is the name of the parent folder you need the folder ID to do this. You need this in order to create folder
//Newly created folder ID will always be returned as an output.
var parentfolder = DriveApp.getFolderById(TargetFolder);
var newFolder = DriveApp.createFolder(FolderName);
var currentFolders = newFolder.getParents();
while (currentFolders.hasNext())
{
var currentFolder = currentFolders.next();
currentFolder.removeFolder(newFolder);
}
parentfolder.addFolder(newFolder);
var folderID = newFolder.getId();
return folderID;
};
Once I declare parentfolder nothing happens. No error, no nothing its just stuck. As mentioned i have this same exact code running in another sheet and it works fine. Anyone have any thoughts?