Here is the script in the table that runs the editor:
function ed2view() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var eds = ss.getEditors(); var ed = eds[1]; ss.removeEditor(ed); ss.addViewer(ed); } It does not work, because, apparently, by the time addViewer () the rights have already been revoked.
If just addViewer (), without removeEditor (), also does not work: If this user has already been a list of editors, this method has no effect .
On the other hand, through the table interface the editor can lower its access rights to the Viewer.
Please advise how to properly lower access rights.
UPD Solution found, thanks, @oshilaer. The original error "ReferenceError: The object" Drive "was not defined" was caused by the fact that the Drive API was not enabled: Script Editor: Resources / Additional functions in the Google API console .