I hope I can explain this clearly.
I have a Googlesheet with a "Ticket" Sheet and a "Customner Data" Sheet. Ticket sheet has Column A as "Ticket Number", Column B as "Customer Name" Customer Data Sheet has column A Customer number, Column C "First Name", Column D "Last Name".
I have a script that as each customer is added to a new row it creates a folder in a folder in drive in the format "Lastname Firstname - Customernumber"
What I am trying to do is as a new row is added to the "Ticket" sheet the script can find the customer folder then add child folder named "TicketNumber".
Here is the code I have been trying so you can see where I am stuck. Thank you
//Global
var googleFolderID = ('DRIVE FOLDER ID');
var ss = SpreadsheetApp.getActive();
function createTicketFolder() {
// identify the sheet where the data resides
var ss = SpreadsheetApp.getActive();
var sheet = ss.getSheetByName("Tickets");
//Select the column we will check for the first blank cell
var columnToCheck = sheet.getRange("A:B").getValues();
// Get the last row based on the data range of a single column.
var lastRow = getLastRowSpecial(columnToCheck);
//identify the cell that will be used to name the folder
var ticketNumber = sheet.getRange(lastRow,1,1,1);
var customerNumber = sheet.getRange(lastRow,2,1,1);
//identify the parent folder the new folder will be in
var parentFolder=DriveApp.getFolderById(googleFolderID);
// Find Customer folder within parentFolder, formatted as "Lastname Firstname - CustomerNumber"
//Need Help here
//create the new folder
var newFolder=customerFolder.createFolder(ticketNumber);
};
function getLastRowSpecial(range){
var rowNum = 0;
var blank = false;
for(var row = 0; row < range.length; row++){
if(range[row][0] === "" && !blank){
rowNum = row;
blank = true;
}else if(range[row][0] !== ""){
blank = false;
};
};
return rowNum;
};
The Google sheets The "Ticket" Sheet
The "Customer Data" Sheet
Google Drive Folder This is how the google drive folders are formatted.
So from the sheets above I need to find the customer folder and add a subfolder with ticket number as folder name.
var customerNumber = sheet.getRange(lastRow,2,1,1);
. It will be easier to help you if you could provide a copy of your spreadsheet. – ziganotschka