Hi everyone,
I own the google sheet file and give restricted access to authorized editors.
I have a protected template tab (model). I created a script for editors to duplicate the model tab.
Of course the protections are not duplicated (it is a known fact)
So I scripted the protections to copy each other.
However, by duplicating the model tab, via my script, the editor still becomes co-owner (with me) of the created tab. and as a result can modify the protected areas.
here below the script part using by editors :
var me = Session.getActiveUser().getEmail();
var p = model.getProtections(SpreadsheetApp.ProtectionType.SHEET)[0];
var p2 = sheet.protect();
p2.setDescription(p.getDescription());
var ranges = p.getUnprotectedRanges();
var newRanges = [];
for (var i = 0; i < ranges.length; i++) {
newRanges.push(sheet.getRange(ranges.getA1Notation()));
}
p2.setUnprotectedRanges(newRanges);
p2.removeEditors(p2.getEditors());
p2.removeEditors([me]);
I even tried to delete removeEditors(e-mail) but it doesn't work, the editor remains co-owner with me.
Is my project possible ?
thanks