Home > Software design >  How to fetch a spreadsheet Id without opening the spreadsheet?
How to fetch a spreadsheet Id without opening the spreadsheet?

Time:07-13

Basically question.

I tried this piece of code but It just returns: TypeError: quoteName.getId is not a function

    quoteTemp = SpreadsheetApp.getActiveSpreadsheet();
var projectName = sheet.getRange('C10').getValue().toString();
projectName = projectName.replace('Project: ', '-');
var quoteName = companyName   projectName   '-'   finalCode;
quoteTemp.copy(quoteName);
var sheetId = quoteName.getId();
SpreadsheetApp.openById(sheetId)
SpreadsheetApp.setActiveSpreadsheet(quoteName)
Logger.log(sheetId);

CodePudding user response:

As a guess. Try to change the line:

quoteTemp.copy(quoteName);

To:

quoteName = quoteTemp.copy(quoteName);
  • Related