问题
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