Reputation: 13
I"m trying to run a script against DocsList that will gather the list of viewers and editors and in turn perform some "work" against them. (Specifically, I'm trying to strip rights from the file in question). It's works perfectly for users. For groups though, it returns the group name and not the email. I can't find any way using apps scripts to retrieve the group email address from that information. If I run fileObject.removeEditor(Group Name) is tells me it's an invalid email (which is entirely true).
I'm open to suggestions... I'm completely stuck here.
Alternatively, I'm open to a way I haven't thought of to remove all sharing rights to a bunch of files in Google Docs.
function getDocs(){
var myFolders = DocsList.getAllFolders();
var myFiles = DocsList.getAllFiles(0,10);
var mySharing = new Array();
for(x in myFiles){
mySharing[x] = [myFiles[x].getId(), myFiles[x].getEditors(), myFiles[x].getViewers()];
for(y in mySharing[x][1]){
if(mySharing[x][1][y].toString() != "[email protected]"){
myFiles[x].removeEditor(mySharing[x][1][y]);
}
}
for(y in mySharing[x][2]){
if(mySharing[x][2][y].toString() != "[email protected]"){
myFiles[x].removeEditor(mySharing[x][1][y]);
}
}
}
}
Upvotes: 1
Views: 310
Reputation: 1809
Thanks for bringing this up. This is a problem with the way the getEditors/getViewers methods handle groups. I've raised this issue for you in the issue tracker. Please star it to be updated on the progress.
Upvotes: 2