I want to define a specific sheet as an id value using the getSheetById() function.
It is said that getSheetId() is undefined and does not work.
The code I used is as follows.
function getSheetById(gid){
for (var sheet in SpreadsheetApp.getActiveSpreadsheet().getSheets()) {
if(sheet.getSheetId() == gid){
return sheet;
}
}
}