Advertisement
Guest User

Untitled

a guest
Mar 5th, 2024
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // https://stackoverflow.com/questions/71649320/
  2.  
  3. function myFunction() {
  4.   var ss = SpreadsheetApp.getActiveSpreadsheet();
  5.  
  6.   var editors_emails = ['[email protected]', '[email protected]'];
  7.   var viewers_emails = ['[email protected]', '[email protected]'];
  8.  
  9.   var editors = ss.getEditors();
  10.   var i = editors.length
  11.   while (i--) {
  12.     if (editors_emails.includes(editors[i].getEmail())) continue; // skip if the editor is the array
  13.     ss.removeEditor(editors[i]);
  14.   }
  15.  
  16.   var viewers = ss.getViewers();
  17.   var i = viewers.length
  18.   while (i--) {
  19.     if (viewers_emails.includes(viewers[i].getEmail())) continue; // // skip if the viewer is the array
  20.     ss.removeViewer(viewers[i]);
  21.   }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement