Non-Google accounts are no longer able to execute scripts

Asked 2 years ago, Updated 2 years ago, 52 views

I tried to protect cells in the spreadsheet with Google apps Script, and when I ran the script below, it didn't enter my Google account, and when I ran the script, I got the following error.

Script XXXX encountered an error

「It says that everyone who knows the link can edit it, and it can be edited by anyone other than your Google account.

The script you moved is the code below in the official help.

[Official Help]
https://developers.google.com/apps-script/reference/spreadsheet/protection

//Protect range A1:B10, then remove all other users from the list of editors.
 vars = SpreadsheetApp.getActive();
 var range=ss.getRange('A1:B10');

 var protection=range.protect().setDescription('Sample protected range');

 // Ensure the current user is an editor before removing others. Otherwise, if the user's edit
 // permission comes from a group, the script will throw an exception upon removing the group.
 varme=Session.getEffectiveUser();
 protection.addEditor(me);
 protection.removeEditors(protection.getEditors());
 if(protection.canDomainEdit()){
   protection.setDomainEdit(false);
 }

Also, when I ran the script from the Google account login state, it was successful.
I'm having trouble with this script, including other spreadsheets. All scripts have the same symptom.

If anyone knows, please let me know.

google-apps-script

2022-09-30 21:22

1 Answers

I will answer myself.
It was irrelevant to perform cell protection on the official help spreadsheet.
If you are simply not logged in to your Google account, you do not appear to have permission to run Google apps Script.


2022-09-30 21:22

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.