0

I'm trying to open a new sheet in my spreadsheet and set some values inside it, using google apps script. When calling the function, I provide one argument, which will be used to name the new sheet.

When I call the function in the sheet itself, it looks like that:

Call the function from the sheet

Unfortunately, I get an error saying I don't have the permissions to call the 'insertSheet()' function, although I already gave it permissions. Also, when running the same function from the script editor, it works fine, and the new sheet is being added.

Permissions error

I thought it might be some permissions problem, but I see no sense in that, since I already granted those permissions. The script was created through the sheet itself, so it should be bounded correctly.

Any idea of what am I missing? Please help :)

1 Answer 1

1

Sorry, but what you're trying to do is not possible in that way as the docs say:

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

If your custom function throws the error message You do not have permission to call X service., the service requires user authorization and thus cannot be used in a custom function.

When you use a custom function, the spreadsheet is calling the function, therefore even if you granted permissions, those permissions were for you, not the spreadsheet. That is the problem you are having.

You could use Custom Menus in G Suite, though. That would allow you to have a menu or a button made by you in your spreadsheet, which could call a function in your Apps Script code.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for taking the time to respond.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.