I have been trying to get active sheet id from [this answer][1] using:
function getActiveSheetId(){
var id = SpreadsheetApp.getActiveSheet().getSheetId();
Logger.log(id.toString());
return id;
}
but my logger logs 0. Is there some other way to get the same? I want to read this sheet from another sheet file and then perform the operations.
[1]: https://stackoverflow.com/questions/26682269/get-google-sheet-by-id#:~:text=filter(%20function(s)%20%7B,Logs%20or%20use%20the%20debugger.
There is nothing wrong with the code.
It returns 0 if you apply this function to the first sheet, which is the correct sheet id as you can see from the url of the page:
and if you apply the same function to a different sheet you get again the correct sheet id:
If you want to get a sheet by its id then refer to this post:
Get Google Sheet by ID?
Example:
for example if you want to get the first sheet (id=0) then do that:
And then you can apply all the sheet operations to this
sheetas usual.