google-apps-scriptgoogle-sheetsgoogle-sheets-formulagoogle-sheets-custom-function

You do not have permission to call setDataValidation


I am trying to use a custom function. Whenever I try to use it as a formula from within sheets and run it on a cell it throws the error:

You do not have permission to call setDataValidation

But when I run it from the script editor it runs perfectly fine. How can I make it work without having to click Run from the script editor?

Note: I prefer not to use triggers.


Solution

  • SpreadsheetApp service is read only when called with custom functions

    Ocordova has the right idea. The article he cited discusses how the SpreadsheetApp service is...

    Read only (can use most get*() methods, but not set*()). Cannot open other spreadsheets (SpreadsheetApp.openById() or SpreadsheetApp.openByUrl()).

    If you want to be able to edit cells, you will need to call the functions from a custom menu.