1

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.

Rubén
  • 34,714
  • 9
  • 70
  • 166
Drewdavid
  • 3,071
  • 7
  • 29
  • 53
  • Does this answer your question? [No permission to call msgBox in Google Apps Scripting](https://stackoverflow.com/questions/10506105/no-permission-to-call-msgbox-in-google-apps-scripting) – Rubén Jun 28 '20 at 00:02

1 Answers1

2

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()
}
Jack Brown
  • 5,802
  • 2
  • 12
  • 27