Protect a cell for everyone except for function

别等时光非礼了梦想. 提交于 2020-04-18 06:47:19

问题


I am new to the world of apps script and I would like to know if is it possible to protect a cell for everyone(they can't change the value directly) but can be changed by a function that will be called by everyone ? Thanks

edit: the user can't change direclty the cell but he has a button with a script which shloud be able to change the value of the protect cell but currently if I put the cell in "protect sheets and range" the script doesn't work


回答1:


Yes, it is possible.

First Option

Use the service account which would impersonate the owner of the document.

Here is an example how to incorporate a service account in Apps Script.

Make sure that you give to the service account the necessary scopes and enable domain-wide delegation.

Second option

Deploy your script as a Web App and execute it as you

Third Option

Use an installable trigger - this will run on your behalf after you authorize it. You can e.g. set-up an installable onEdit trigger that will fire the script function if a certain cell (e.g. "A20") is edited by the user.



来源:https://stackoverflow.com/questions/58504763/protect-a-cell-for-everyone-except-for-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!