Reputation: 3192
Attempting to insert the value of the spreadsheet ID, and sheet/tab IDs into cells in my spreadsheet.
Found this answer and tried the code as a script:
How to fetch the ID of a Google Spread Sheet via Google Apps Script?
Then I ran into this error when I tried to run it as a cell-based function:
Error You do not have permission to call msgBox (line 2).
As per No permission to call msgBox in Google Apps Scripting.
Hoping there might be a workaround and/or proper way to do this that someone could point out.
Upvotes: 1
Views: 1101
Reputation: 5892
When using a custom function to write a value to the cell, you can just use return
to write the value to the cell.
So your modified function would be
function getId() {
return SpreadsheetApp.getActiveSpreadsheet().getId()
}
Upvotes: 2