title: How to change access rights to a spreadsheet from Editor to Viewer?
body: <p>Here is the script in the spreadsheet that the editor run:</p>
  
  <pre><code>function ed2view() {
    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var eds = ss.getEditors();
    var ed = eds[1];
    ss.removeEditor(ed);
    ss.addViewer(ed);
  }
  </code></pre>
  
  <p>It does not work, because, apparently, by the time addViewer() the rights have already been revoked.</p>
  
  <p>If just addViewer(), without the previous removeEditor(), also does not work: <a href="https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet#addvieweremailaddress" rel="nofollow noreferrer">If the user was already on the list of editors, this method has no effect</a>.</p>
  
  <p>On the other hand, through the interface of the spreadsheet, the editor can lower its access rights to the Viewer.</p>
  
  <p>Please advise how to correctly change access rights.</p>