I am not able to replicate the result of these actions (see pictures) WITH GOOGLE APPS SCRIPT CODE.
Here are the actions:
Open a SpreadSheet with Google Spreadsheets
Right click -> Protect Range...
Click on this
Then click on this
And
I had NO success by trying this code:
SpreadsheetApp.addEditor('theEmailThatIWantToEnabled@email.com');
Here the solution of this problem.
In my specific case the permissions were "by sheets" and NOT "by ranges" .
So here a small working code:
var ss = SpreadsheetApp.getActive();
var protections = ss.getProtections(SpreadsheetApp.ProtectionType.SHEET);
for (var i = 0; i < protections.length; i++) {
protections[i].addEditor('theEmailYouWantEnabled@email.com');
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.