Access - Scripts Bound to Google Sheets

2019-09-10 22:54发布

问题:

From the documentation of the the bound script: https://developers.google.com/apps-script/guides/bound

"Only users who have permission to edit a spreadsheet, document, or form can run its bound script. Collaborators who have only view access cannot open the script editor, although if they make a copy of the parent file, they become the owner of the copy and will be able to see and run a copy of the script."

This feature is kinda limited. I have created a big sheet that are used by multiple users. I need the script to be executable by Read Only access users. The script that I created are not making changes to the document, so it should not affect by the access level of the users.

  • Administrator have Edit access to the document. They have access to all calculation/ configuration cells/ sheet.
  • Managers have Edit access to the document. Managers have Edit access to most of the cells/ sheet. Managers task is to update the cells
  • All remaining users only have Read Only access to the document. They can view cells and the automated calculation.

Because the cells have too many columns, I have created a button (eventually I want to move it to onOpen) for easy navigation to a specific cell. This is done dynamically based on today's date. This is working fine as expected for Administrator and Manager (have Edit access), however not available for the rest of the users with Read Only access.

Is there any workaround for this?

Thanks

回答1:

Unfortunately not. You are the edge case. The whole point of GAS is to make editing easier, providing tools. A Google document/Spreadsheet/etc. normally isn't THAT hard to maneuver through.

However, if your REALLY want viewers to see specific parts of your spreadsheet, but not edit it, you could try making a standalone script. Have it pull data from the spreadsheet using the spreadsheet's id and then project it on the HTML page, in a table or list.



回答2:

I Agree with EvSunWood, though I would go about the task in a slightly different way. You could give read only access to the main sheet to the user. And then give them full access to a separate sheet with code attached which onOpen updates itself from the original with all of the latest data and then navigates to the appropriate row.



回答3:

I agree too with this answer, it's not possible to allow view only users to execute scripts, but contrary to using an script to overwrite edited data, I suggest you use sheets/range protection this way we reduce risks like a failure on the script by on open trigger due to "change collisions" caused by several users opening the same file at almost the same time.