Google-sheets – How to prevent editors from accessing the script editor in Google Sheets

google sheetsgoogle-apps-script

I have an auto sort script on a Sheets document that I will be giving multiple people editing permission to, to add to the file. I have created a trigger so the script also runs when other users edit the file as well.

The only thing I would like to do now is prevent other users with editing permission from accessing the script editor and changing it. Is it possible to prevent access to script editor for other collaborators with editing permission?

I have read other answers saying to create a standalone script and programmatically create an installable trigger. I have created a standalone script but I don't know how to use it with the Sheets document and when I tried to put in an installable trigger it only seemed to run the script properly once, and when accessing it from another users account I could still access script editor as well.

Best Answer

I see this question is quite old but thought I'd answer for of other searchers in the future.

You can't restrict editors from viewing the script editor.

You can, as you have started to explore, have a standalone script file which connects to the standalone spreadsheet.

In Drive click NEW > MORE > Google Apps Script

You connect the spreadsheet & the script together by using:

var ss = SpreadsheetApp.OpenFileById("[spreadsheetIdHere]")

Once the variable ss is assigned to the spreadsheet you can reference it in the standalone script the same as you would have done if it had been a bound script in the script editor.

The spreadsheet ID is the long number (marked as xxxx here) between 2 slashes for instance:

https://docs.google.com/spreadsheets/d/xxxxxxxxxxxxxxxxxxxx/edit#gid=0

I hope that gives you something to go on.