Edward Wu
Edward Wu

Reputation: 495

onOpen "hide sheets" doesn't work for Viewers of a Google Sheet?

I have a "hide sheets" function. I've tried using it as an onOpen function, and also with a On Open trigger.

It works fine if an Editor opens the GS.

But if a Viewer opens the GS, it doesn't work at all. If it's an On Open trigger, I get an error email that "Authorization is required to perform that action." If it's called as an onOpen function, it just doesn't work, but also doesn't generate any errors.

Is there a way to make this work for Viewers?

Upvotes: 0

Views: 347

Answers (2)

Wicket
Wicket

Reputation: 38435

Viewers can't execute scripts including those called by simple triggers like onOpen

One option among many others is to have one spreadsheet for editors and another for viewers then somehow send the changes made by the editors to spreadsheet shared with viewers.

Related

Upvotes: 3

Alessandro
Alessandro

Reputation: 2998

Consideration

onOpen trigger should not perform sensitive actions, at most create a menu.

A simple trigger won't be able to run under this low privileged scope (viewer-only).

A better flow would be to show additional sheets to users who have sufficient permissions, not the other way around.

Reference

Triggers Restrictions

Upvotes: 2

Related Questions