Part of my code in the main file is to transfer or create a formula in a specific cell in a different sheet.
Process:
1. Once triggered, it will get the value in E1 [client name] in the current spreadsheet. it will also get the last row of the data to determine the maximum of rows to be copied.
2. Find it’s folder name based on the client name, the folder has standard name “NEW” – [client name].
3. Then get the file id or the id of the spreadsheet where it’s filename contains “Client Worksheet”, sometimes named as [client name]: Client Worksheet.
4. Then it will open the file and select “Client Project” sheetname
5. And will set the cell A1 to a formula like a query with importrange
Here is my existing code:
function transferTasks() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var shtClient = ss.getSheetByName("SEO Deliverables Template");
var cName = shtClient.getRange(1,5).getValue();
var lastRow = shtClient.getLastRow();
var folder = "NEW - " + cName;
var folderID = getFolderID(folder); //get the folder ID of the client
//the getfolderID function is successfull on getting the folder ID
//get the file ID of the client worksheet file
var cWorkSheet = DriveApp.getFolderById(folderID).searchFiles('title contains Client Worksheet');
while (cWorkSheet.hasNext()) { //here is the error: invalid argument
var file = cWorkSheet.next();
var fileID = file.getId();
}
//transfer the data from SEO Deliverables Template to client folder template
var sourceFile = ss.getSheetByName("Sydney Office Projects");
var shtTargetFile = DriveApp.getFileById(fileID);
var shtTarget = shtTargetFile.getSheetByName("Client Project Calendar");
shtTarget.getRange(1,1).setValue="testing"
}
testing is should be replaced by a code here:
=IFERROR(query(IMPORTRANGE("123456789","'sheet'!A2:I"), " select * where Col6 = 'clientname' label Col1 'Assigned Date'",1),"")
Any help on what code should be used?
2
Answers
it i now working, one more thing for this to run is the setFormula at the..
setFormula is now working: